learn java
The moose likes JSP and the fly likes How to pass value to other page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to pass value to other page" Watch "How to pass value to other page" New topic
Author

How to pass value to other page

Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126
Hi

I am using -:

String name="myName";
RequestDispatcher disp = request.getRequestDispatcher("a.jsp");
disp.forward(request, response);

now i want to pass this variable ( name ) to other page where i am forwarding the page and i write -:

RequestDispatcher disp = request.getRequestDispatcher("a.jsp?name=<%= name%>");
disp.forward(request, response);

but it is givimg error that String Constants are not closed properly,
but when i write -:

RequestDispatcher disp = request.getRequestDispatcher("a.jsp?name=amit");
disp.forward(request, response);

then it works fine, could you please tell me the reason and what is the proper way.

Thanks
Regards
Gaurav
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you're already in a scriptlet block, you don't need the JSP expression.


Just use the variable.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: How to pass value to other page