Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pass information to another servlet/jsp
12-14-2010, 08:44 AM
Post: #1
Pass information to another servlet/jsp
You set attributes on your request object and then forward the request object to the other servlet/jsp.

For a simple string

request.setAttribute("foo", "Real's HowTo");

A parameter received by the first servlet to the second one

String requestVar = request.getParameter("sitename");
request.setAttribute("foo", requestVar);

A Bean

MyBean myBean = new MyBean();
myBean.setFooProperty("Real's HowTo");
request.setAttribute("foo", myBean);

Then you forward the request

RequestDispatcher dispatch = request.getRequestDispatcher("next.jsp");
dispatch.forward(request, response);
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:



Send your comments, Suggestions or Queries regarding this site at info@tutorials4u.net

Copyright © 2010 Tutorials4u.net All Rights Reserved