the button (when activated) submits a post request to the servlet, the servlet sets some information in the http requests and forwards to the JSP.
What part of that don't you get working? It's rather basic...
Hello Friend,
Index.jsp :
--------------------------------------------------------------
<html>
<head>
<title></title>
</head>
<body>
<h2></h2>
<form method="post" action="displayname">
<% String name="";%>
<% if(request==null){
name="";
}
else{
name=request.getParameter("name");
}
%>
Display Name:
<input type="text" name="name" value=<%=name%> />
<br>
<input type="submit" name="display" value="Display" />
</form>
</body>
</html>
-------------------------------------------------------
HelloServlet.java
-----------------------------------------------------------------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HelloServlet extends HttpServlet{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
request.setAttribute("name", "Pradeep");
getServletContext()
.getRequestDispatcher("/view.jsp").forward(request, response);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
getServletContext()
.getRequestDispatcher("/view.jsp").forward(request, response);
}
}
--------------------------------------------------------------
Any wrong in this code??
please help me try to debug.. Thanks a lot!
- KINO