• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parmeter type in a URL on a JSP

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Is it only possible to add strings as values in URL that is created on a JSP page.
May bee a Dumb Question but is can save some work for mee backend when a URL is selected and I already have they Object with all the information.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65526
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. HTTP is a text-based protocol.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Yes. HTTP is a text-based protocol.

Did you mean that it is only String that can be handled.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the parameter should be String only.

If you want to send the Object to other JSP/Servlet.

Set it as an attribute in any of the scope like request.setAttribute("obj",yourActualObject) and get it on other jsp/servlet using request.getAttribute('obj")
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siva Masilamani wrote:Yes the parameter should be String only.

If you want to send the Object to other JSP/Servlet.

Set it as an attribute in any of the scope like request.setAttribute("obj",yourActualObject) and get it on other jsp/servlet using request.getAttribute('obj")


I thougth that it was not possible to add as attribut on the request, since it was not availble after the JSP was submitted.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you setting the attribute in the request scope it will be available where the request is received and processed.

If you are setting it in the session scope it is available for the entire active session.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65526
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thomas colding wrote:I thougth that it was not possible to add as attribut on the request, since it was not availble after the JSP was submitted.

That is correct. A request-scoped variable (aka "attribute") is only available during the request in which it is established. It's usually used for passing information from a page controller to its JSP view.

For a scoped variable to be available in subsequent requests, you'll need to establish the scoped variable in session scope.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How Do I retrieve the object again in the Process action after the input is submitted.

I tried as followed
Collection collection= (Collection) session.getAttribute("SOAPOBJECt");

But it seem not to work, is it not possible to put objects in a Collection an then do a loop to find the match.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thomas colding wrote:How Do I retrieve the object again in the Process action after the input is submitted.

I tried as followed
Collection collection= (Collection) session.getAttribute("SOAPOBJECt");

But it seem not to work, is it not possible to put objects in a Collection an then do a loop to find the match.


Ok, I found the Solution, I had to cast the Object as Class it originated from.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!