• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing parameters from one jsp page to another

 
Ted Dong
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have two jsp pages and I want to pass parameters from one to another. I was using response.sendRedirect("myjsp.jsp?Parameters") and this works fine. However... if the length of the parameter is very long (ie, thousands of characters) this method does not work. Is there another way of passing parameters that can handle large sizes of data?
Thanks.
-td
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that personally I don't use this but it is possible...
If there isa session you can temorarily store the data on the session and read it at the other end as long as you remember to clear the data from the session. Otherwise you'll end up choking your server.
Just a question, is it essential to use res.sendRedirect?
Why not include or forward the request?
Dave.
 
Ted Dong
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
Thanks for the response.
No, it is not essential to use response.sendRedirect(). That just happens to be the method I am using. I am not familiar with how to include or forward the request. Do you have any examples?
Also, the code that I have on the jsp page that is receiving the parameters looks like:
Enumeration parmEnum = request.getParameterNames();
String parmName;
while ( parmEnum.hasMoreElements())
{
parmName = (String)parmEnum.nextElement();
JSString += "cybCRAddLaunchParameter(\"" + parmName + "\",\"" + request.getParameter(parmName) + "\");\n";
}
Would I need to change this code if I were to include or forward the response?
Many thanks.
-td
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started writing a huge response then realised I didn't have the time cos everything is going pear-shaped at work.
Basically:

both happen on the server side and allow you to join multiple servlets and jsps together to form a single response to the client. The advantage is that they share the same request and response objects so you can pass data between them.
response.sendRedirect("new_page.jsp);
...is different.
It results in a 301 (?) response code being sent to the client and effectively means (warning, tacky star wars reference coming)
"This isn't the file you're looking for, move along"
The client then sends another request for the page it was told to look for and gets this page back instead.
There are reasons to use both but typically you use include and forward since they are more efficient because they don't result in the extra network call.
Does this cover it?

Dave.
 
Ted Dong
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave!
That does help a lot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!