No it didn't work with the seesion attributes.. plz tell me where am i going wrong.. my code is below
THIS IS THE JSP FILE CODE
-------------------------
<html>
<head>
<title>
TEST </title>
</head>
<body>
<%
String sample = "";
if(request.getParameter("sample")!=null)
{
sample = request.getParameter("sample");
}
session.setAttribute("sample",sample);
%>
<h1>
JBuilder Generated JSP
</h1>
<form name = "encryption" method="GET" action = "http://localhost:8080/servlet1">
<br>Enter password : <input name="sample" size="20">
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="Reset">
<br>
</p>
</form>
</body>
</html>
THE SERVLET CODE IS AS BELOW:
------------------------------
package test_date;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Servlet1 extends HttpServlet {
static final private String CONTENT_TYPE = "text/html";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String sample = "";
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
sample = request.getSession().getAttribute("sample").toString();
out.println("The sample value is " + sample);
out.println("<head><title>Servlet1</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a GET." + sample+ "This is the reply.</p>");
out.println("</body></html>");
}
//Clean up resources
public void destroy() {
}
}
where am i going wrong..... y isnt the sample string passed on from jsp tp the servlet..!!???