passing request to a second jsp
Hi Guys
I have a jsp (search.jsp) that deals with a request from a web form and shows the results in the browser. Im then trying to pass this request to a second jsp (export.jsp) to put the info into an xls file. I can create an xls file on its own by setting the contentType but i cant show the results in a browser and then pass the request to export. Ive read loads of foums and tried jsp:forward and jsp:include both of which dont work. I have also tried requestDispatcher and sendRedirect but cant get it to work.
This is the main problem
Provide a href link capable of either calling export.jsp and passing the request or providing a href link to call a method in search.jsp that will then use a method to pass the request and forward the user.
I have been stuck on this for ages now and have had zero luck. If anyone can help me and provide some sample code that would be brilliant.
Thanks
[934 byte] By [
Ryion69a] at [2007-11-27 10:48:39]

# 1
Put the request in a session variable.
In the first page do
request.getSession().setAttribute("var", yourData);
and in the second page, just get the data from the session
request.getSession().getAttribute("var");
Manuel Leiria
# 3
yes, it may be anything. HashTable/ArrayList/String/int/boolean/etc.,
String myVar = myBO.getVal();
session.setAttribute("value", myVar);
JSP:
String getData = (String)session.getAttribute("value");
skp71a at 2007-7-28 22:28:34 >

# 5
Hi im actually trying to pass the request (a HttpServletRequest object) but when i use the methods suggested above i get an error cannot cast from Object to [type].
I could do the task by passing a formdata object (my own class) and a boolean instead of the request.
I have tried with a boolean and the HttpServletRequest but always get the same error!
Message was edited by:
Ryion69
# 8
Hi Everyone
I have finally got it all working in the end i used a combination of all your advice.
I put all the variables i needed into an object and just passed that using set/getAttribute("value") which worked for my FormData object but would not work for a boolean or HttpServletRequest!
Stars all round!