Main.java:
package ru.Mark; 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; public class Main extends HttpServlet{ /** * */ private static final long serialVersionUID = 1L; @Override public void doPost(HttpServletRequest req,HttpServletResponse resp) throws IOException, ServletException{ resp.setContentType("text/html"); String name=req.getParameter("login"); String password=req.getParameter("pass"); req.setAttribute("login", name); req.setAttribute("pass", password); RequestDispatcher disp=getServletContext().getRequestDispatcher("index.jsp"); disp.forward(req, resp); } }
index.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>Page!</title> </head> <body> <h2>First page!</h2> <form action="index.jsp" method="post"> Login:<input type="text" name="login"><br> Password<input type="text" name="pass"><br> <input type="submit" name="send"><br> </form> login: ${login}<br> password: ${pass}<br> </body> </html>
Why login and password is not displayed on the index page?
web.xml
, and do not say that you do not have it. - Roman C