Por que no funciona???
Publicado por Jaime (1 intervención) el 27/03/2010 04:39:32
Alguien sabe por que no funciona
gracias
lo llamo asi
http://localhost:8080/index.html
index.html
-------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form name="f" method="post" action="http://localhost:8080/HolaMundo">
<script type="text/javascript">document.f.submit();</script>
</form>
</body>
</html>
-------------------
HolaMundo
-------------
package saludo;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class HolaMundo
*/
public class HolaMundo extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public HolaMundo() {
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher dis;
dis = getServletContext().getRequestDispatcher("/hola.jsp");
dis.forward(request,response);
}
}
---------------
hola.jsp
----------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
</head>
<body>
<table>
<tr>
<td>Hola mundo</td>
</tr>
</table>
</body>
</html>
-----------------------
web.xml
----------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>HolaMundo</display-name>
<servlet>
<servlet-name>HolaMundo</servlet-name>
<servlet-class>saludo.HolaMundo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HolaMundo</servlet-name>
<url-pattern>/HolaMundo</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
---------------
server.xml
-----------
<Server port="8005" shutdown="SHUTDOWN">
......
<Context docBase="HolaMundo" path="" reloadable="true" source="org.eclipse.jst.j2ee.server:HolaMundo"/></Host>
....
</Server>
----------------
gracias
lo llamo asi
http://localhost:8080/index.html
index.html
-------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form name="f" method="post" action="http://localhost:8080/HolaMundo">
<script type="text/javascript">document.f.submit();</script>
</form>
</body>
</html>
-------------------
HolaMundo
-------------
package saludo;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class HolaMundo
*/
public class HolaMundo extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public HolaMundo() {
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher dis;
dis = getServletContext().getRequestDispatcher("/hola.jsp");
dis.forward(request,response);
}
}
---------------
hola.jsp
----------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
</head>
<body>
<table>
<tr>
<td>Hola mundo</td>
</tr>
</table>
</body>
</html>
-----------------------
web.xml
----------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>HolaMundo</display-name>
<servlet>
<servlet-name>HolaMundo</servlet-name>
<servlet-class>saludo.HolaMundo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HolaMundo</servlet-name>
<url-pattern>/HolaMundo</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
---------------
server.xml
-----------
<Server port="8005" shutdown="SHUTDOWN">
......
<Context docBase="HolaMundo" path="" reloadable="true" source="org.eclipse.jst.j2ee.server:HolaMundo"/></Host>
....
</Server>
----------------
Valora esta pregunta
0