user is null in servlet. Pls let me if doing mistake.
i m trying to get all html element in bean rateCode.jsp
<%@page import=\"com.hermes.data.Rat
The problem (and its solution) is as follows:
You create a request scope bean user but once the page is loaded the request is finished and gone - no wonder it is null in the next request which is completely unrelated to this one. What you probably wanted to do is the following:
1) Remove the from your jsp page completely so it will look as follows:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="com.hermes.data.RateCode_" %>
Rate Code
2) Your form now redirects to another jsp, the forwarder. It looks like follows:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
What this does: it creates the bean in request scope - the request which submitted the form. Then it populates the bean properties with the data from the form and finally it forwards (IN SAME REQUEST, HERE IS THE POINT) to the servlet which does some job.
3) Finally do something in your servlet, I did this for testing purposes:
public class TestServlet extends javax.servlet.http.HttpServlet {
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
RateCode_ code = (RateCode_) request.getAttribute("user");
System.out.println(code);
}
}