26/03/2010, 01:33
|
| | Fecha de Ingreso: marzo-2010
Mensajes: 13
Antigüedad: 14 años, 8 meses Puntos: 0 | |
Respuesta: No me funcionan los servlets AYUDAAA Este es el codigo del index.jsp
----------------------------------------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Servlet_Hola extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
/*
TODO output your page here
*/
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Servlet_Hola</title>");
out.println("</head>");
out.println("<body>");
out.println("<p>");
out.println("Hola <strong>" + request.getParameter("nombre").toString() + "<strong>");
out.println("</p>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
// </editor-fold>
}
---------------------------------------------------------------------------------------------
Y este el del xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Servlet_Hola</servlet-name>
<servlet-class>Servlet_Hola</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet_Hola</servlet-name>
<url-pattern>/Servlet_Hola</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
---------------------------------------------------------------
de todas maneras, es normal que no pueda ver los ejemplos del tomcat????, es que me dice que no esta disponible....
Gracias por responder |