• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Passing parameters from one jsp page to another

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dave!
That does help a lot.
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic