Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass value to other page

 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're already in a scriptlet block, you don't need the JSP expression.


Just use the variable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic