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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to pass value to other page" Watch "How to pass value to other page" New topic

How to pass value to other page

Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126

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.

Ben Souther

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
I agree. Here's the link:
subject: How to pass value to other page
It's not a secret anymore!