Foros del Web » Programación para mayores de 30 ;) » Java »

Ayuda con servlet

Estas en el tema de Ayuda con servlet en el foro de Java en Foros del Web. hola a todos, soy nuevo en esto de los servlet y estoy empezando con hacer un ejemplo sencillo, utilizo el j2sdk 1.4.2 y em tomcat ...
  #1 (permalink)  
Antiguo 21/07/2007, 03:22
Avatar de andresq  
Fecha de Ingreso: enero-2007
Ubicación: Chiapas, México
Mensajes: 161
Antigüedad: 17 años, 3 meses
Puntos: 1
Ayuda con servlet

hola a todos, soy nuevo en esto de los servlet y estoy empezando con hacer un ejemplo sencillo, utilizo el j2sdk 1.4.2 y em tomcat 4.1 y este el codigo

Código PHP:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class PruebaServlet extends HttpServlet
{
    //PROCESAR LAS PETICIONES 
    protected void doGet( HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
    {
        respuesta.setContentType( "text/html" );
        PrintWriter salida = respuesta.getWriter();
        
        //ENVIAR PAGINA XML AL CLIENTE
        
        //EMPEZAR DOCUMENTO XML
        salida.println( "<?xml version "1.0\" ?>");
        
salida.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD " "XHTML 1.0 Strict//EN\" \"http:www.w3.org" "/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
        
salida.println("<html xmlns = \"http://www.w3.org/1999/xhtml\">");
        
        
salida.println("<head><title>Ejemplo de Servlet Simple</title></head>");
        
salida.println("<body>");
        
salida.println("<h1>¡Bienvenido a los servlets!</h1>");
        
salida.println("</body>");
        
        
salida.println("</html>");
        
salida.close();
    }
}
y los errores estan aca
Código PHP:
mport javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class 
PruebaServlet extends HttpServlet
{
    
//PROCESAR LAS PETICIONES 
    
protected void doGetHttpServletRequest peticionHttpServletResponse respuestathrows ServletExceptionIOException 
C:\Tomcat 4.1\webapps\ROOT\servlet\PruebaServlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
C:\Tomcat 4.1\webapps\ROOT\servlet\PruebaServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\Tomcat 4.1\webapps\ROOT\servlet\PruebaServlet.java:5: cannot resolve symbol
symbol : class HttpServlet
location: class PruebaServlet
public class PruebaServlet extends HttpServlet
^
C:\Tomcat 4.1\webapps\ROOT\servlet\PruebaServlet.java:8: cannot resolve symbol
symbol : class HttpServletRequest
location: class PruebaServlet
protected void doGet( HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
^
C:\Tomcat 4.1\webapps\ROOT\servlet\PruebaServlet.java:8: cannot resolve symbol
symbol : class HttpServletResponse
location: class PruebaServlet
protected void doGet( HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
^
C:\Tomcat 4.1\webapps\ROOT\servlet\PruebaServlet.java:8: cannot resolve symbol
symbol : class ServletException
location: class PruebaServlet
protected void doGet( HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException

gracias por la ayuda
__________________
Lo unico constante es el cambio
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:25.