• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

Servlet problem

J

juan carlos@

Guest
hi im trying to deploy a web app but cannot make to work a servlet.

its just goes to the servlet address but doesnt proccess the data that i receive from an html page.

this is my servlet code if someone can help me.

and this is the site address: http://colombiatourssolutions.com:9080/encuesta/encuesta_ES.html

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";
}
}
 
Back
Top