
I want to pass some variables from a JSP page to a servlet. These variables are from the java code of my JSP. In JSP page I did,
String msg="hello"; request.getSession().setAttribute("msg",msg);
String strViewPage="MyServlet"; RequestDispatcher dispatcher = request.getRequestDispatcher(strViewPage); if (dispatcher != null){ dispatcher.forward(request, response); }
In MyServlet.java I have included,
String msg = (String)request.getAttribute("msg");
The problem is the values from JSP to servlet gives null values. I got msg=null.
Is there another way to get java variables from JSP tp servlet?
If there is some error in my code, please point that. Please give me your suggestions.

Please go through the following links:
http://www.roseindia.net/servlets/request-parameter.shtml
http://www.roseindia.net/tutorial/servlet/passParameters.html