Ver Mensaje Individual
  #6 (permalink)  
Antiguo 23/06/2009, 01:27
kaiser1313
 
Fecha de Ingreso: abril-2009
Ubicación: Venezuela
Mensajes: 106
Antigüedad: 15 años
Puntos: 0
Respuesta: Servlets y puerto serial...

Cita:
Iniciado por elAntonie Ver Mensaje
Y el codigo de tu servlet?? y tu web.xml?? Te esta diciendo que no existe ese mapoeo (servletdebienvenida/ServletDeBienvenida)
Ok colocare todo de nuevo:

webapps\cpej5\WEB-INF\web.xml

Código:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app 
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
    "java.sun.com/dtd/web-app_2_3.dtd">

<web-app>


    <!-- General description of your web application -->

    <display-name>Servlets del TEG</display-name>
    <description>
		Servlets para el TEG
    </description>


    <!-- Context initialization parameters that define shared
         String constants used within your application, which
         can be customized by the system administrator who is
         installing your application.  The values actually
         assigned to these parameters can be retrieved in a
         servlet or JSP page by calling:

             String value =
               getServletContext().getInitParameter("name");

         where "name" matches the <param-name> element of
         one of these initialization parameters.

         You can define any number of context initialization
         parameters, including zero.
    -->

  <!--
  <context-param>
    <param-name>webmaster</param-name>
    <param-value>[email protected]</param-value>
    <description>
       The EMAIL address of the administrator to whom questions
       and comments about this application should be addressed.
    </description>
  </context-param>
-->

    <!-- Servlet definitions for the servlets that make up
         your web application, including initialization
         parameters.  With Tomcat, you can also send requests
         to servlets not listed here with a request like this:

           localhost:8080/{context-path}/servlet/{classname}

         but this usage is not guaranteed to be portable.  It also
         makes relative references to images and other resources
         required by your servlet more complicated, so defining
         all of your servlets (and defining a mapping to them with
         a servlet-mapping element) is recommended.

         Servlet initialization parameters can be retrieved in a
         servlet or JSP page by calling:

             String value =
               getServletConfig().getInitParameter("name");

         where "name" matches the <param-name> element of
         one of these initialization parameters.

         You can define any number of servlets, including zero.
    -->

    <servlet>
      <servlet-name>bienvenida1</servlet-name>
      <description>Servlet que Envia por Puerto Serial</description>
    <servlet-class>ServletDeBienvenida</servlet-class>
    
<!-- 
        <init-param>
            <param-name>
                uploadDir
            </param-name>
            <param-value>
                /tmp 
            </param-value>
        </init-param>
-->
    </servlet>

    <servlet-mapping>
      <servlet-name>bienvenida1</servlet-name>
      <url-pattern>/bienvenida1</url-pattern>
    </servlet-mapping>

    <!-- Define the default session timeout for your application,
         in minutes.  From a servlet or JSP page, you can modify
         the timeout for a particular session dynamically by using
         HttpSession.getMaxInactiveInterval(). -->

    <session-config>
      <session-timeout>30</session-timeout>    <!-- 30 minutes -->
    </session-config>


</web-app>
webapps\cpej5\WEB-INF\classes\ServletDeBienvenida.class
webapps\cpej5\WEB-INF\classes\ServletDeBienvenida.java

Código:
package servletdebienvenida;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class ServletDeBienvenida extends HttpServlet
{

    protected void doGet(HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
    {
		respuesta.setContentType ("text/html");
		PrintWriter salida = respuesta.getWriter();

		salida.println("<?xml version = \"1.0\"?>");
		salida.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD " + "XHTML 1.0 Strict//EN\" \"w3.org" +"/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
		salida.println("<html xmlns = \"w3.org/1999/xhtml\">");
		salida.println("<head>");
		salida.println("<title>Un ejemplo de Servlet simple</title>");
		salida.println("</head>");
		salida.println("<body>");
		salida.println("<h1>Bienvenido a los Servlets</h1>");
		salida.println("</body>");
		salida.println("</html>");
		salida.close();
    }
}
webapps\cpej5\servlets\ServletDeBienvenida.html

Código:
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	
<!-- Fig. 24.6: ServletDeBienvenida.html -->

<html xmlns = "w3.org/1999/xhtml">
<head>
	<title>Manejo de una peticion Get de HTTP</title>
</head>

<body>
	<form action "cpej5/bienvenida1" method "get">
	
		<p><label>Haga Clic en el Boton para Invocar el Servlet
			<input type = "submit" value = "Obtener documento HTML" />
		</label></p>
	</form>
</body>
</html>
Ok alli estan las rutas de los archivos y sus contenidos, por favor decirme que esta mal porque he hecho varias cosas y nada...

PS: He tenido que borrar los http y www para poder publicar el mensaje ya que no me dejaba publicar direcciones webs...