• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

servlets problems plz help

J

juan carlos@

Guest
ok im using plesk 8.0 and im trying to update a web app to tomcat server but get me servlet to get the parameters its just stuck in ther servlet but doenst do anything.

this is my servlet code if anyone can help me plz


import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import values.OpcionValue;


public class EncuestaServlet extends HttpServlet {

OpcionValue opcionValue;
OpcionDAO opcionDAO;


public void init(ServletConfig config) throws ServletException
{
System.out.println ( "Iniciando Servlet Administracion de Encuesta..." );
opcionValue = new OpcionValue();
opcionDAO = new OpcionDAOMySQL();
}

public void destroy()
{
}

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request,response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request,response);
}

public void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{

OpcionValue listo = null;
int filas = 0;
///////////////
System.out.println("Entrando Servlet encuesta");
String accion = request.getParameter("accion");
int codigo_pregunta = 1;//por defecto es 1 ya que solo se maneja una pregunta si fuera dinamico tocaria recibirlo del Jsp
int hits = 1;//el voto q se suma al clickear
String texto = new String("");//el texto que acompana a la pregunta pero esta predefinido en la BD asi q se pasa un Null
String op = new String ("");//la opcion seleccionada de la pregunta
int opNum = 0;
////////////
String error = null;



try
{

System.out.println("la accion q llego " +accion);

if (accion.equals("voto"))
{
op = request.getParameter("Radios");
opNum = Integer.parseInt(op);

opcionValue = new OpcionValue(codigo_pregunta,hits,texto,opNum);//al referenciar el objeto hits y texto no afectan las busquedas ni las insercniones con valores indispensables

hits = opcionDAO.buscarXVotos(opcionValue);
hits = hits +1;

listo = new OpcionValue(codigo_pregunta,hits,texto,opNum);


filas = opcionDAO.votar(listo);

RequestDispatcher dispatcher = request.getRequestDispatcher("/exitoES.html");

if (dispatcher != null)
{
dispatcher.forward(request,response);
}


}

if (accion.equals("votoIN"))
{
op = request.getParameter("Radios");
opNum = Integer.parseInt(op);

opcionValue = new OpcionValue(codigo_pregunta,hits,texto,opNum);//al referenciar el objeto hits y texto no afectan las busquedas ni las insercniones con valores indispensables

hits = opcionDAO.buscarXVotos(opcionValue);
hits = hits +1;

listo = new OpcionValue(codigo_pregunta,hits,texto,opNum);


filas = opcionDAO.votar(listo);

RequestDispatcher dispatcher = request.getRequestDispatcher("/exitoIN.html");

if (dispatcher != null)
{
dispatcher.forward(request,response);
}


}

if (accion.equals("resultados"))
{
Collection resultados = new Vector();

resultados = opcionDAo_ObtenerResultados();
System.out.println("Lo que llego al servlet: " + resultados);

request.setAttribute("todo",resultados);


RequestDispatcher dispatcher = request.getRequestDispatcher("/index.html");

if (dispatcher != null)
{
dispatcher.forward(request,response);
}


}

if (accion.equals("resultadosIngles"))
{
Collection resultados = new Vector();

resultados = opcionDAo_ObtenerResultados();
System.out.println("Lo que llego al servlet: " + resultados);

request.setAttribute("todo",resultados);


RequestDispatcher dispatcher = request.getRequestDispatcher("/resultados_IN.jsp");

if (dispatcher != null)
{
dispatcher.forward(request,response);
}


}




}
catch(Exception e)
{
e.printStackTrace();
request.setAttribute("e",e);
RequestDispatcher dispatcher = request.getRequestDispatcher("/procesar_error.jsp");
if (dispatcher != null) dispatcher.forward(request,response);
}
}

public String getServletInfo() {
return "SimpleServletAdministrador";
}
}
 
You could try to tail -f the log file to see the errors in near realtime.
 
help

thx for the help.

can u please tell me how to do the -f thing
 
Yep, you can use at shell:

# tail -f /var/log/tomcat4/catalina.out

I presume you have the same path, if not change it.

Hope it helps.
 
Back
Top