• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

<jsp:forward> with params

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<jsp:forward page"/TestServlet">
<jsp:param value="sort" name="action"/>
</jsp:forward>


Why request.getParameter("action") gives me null in TestServlet. :confused:
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Veeresh Hubballi,

you forgot the equal sign in line 1 after the page Attribut. Then it should work.

<jsp:forward page="/TestServlet">




 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A forward simply forwards the existing request to another resource. It does not create a new request, so you can't add params to it.

If you have data you need to pass along, simply put that data in request scope.
 
Marc Pfaller
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:A forward simply forwards the existing request to another resource. It does not create a new request, so you can't add params to it.

If you have data you need to pass along, simply put that data in request scope.



Hello Bear Bibeault,

i tested the jsp Code from Veeresh Hubballi with NetBeans in the index.jsp and created a TestServlet
in which i read the Parameter: String myAction = request.getParameter("action");
and output it.
It outputs the Parameter Value normally.

jsp:forward with jsp:param no Problem.

OracleDocs also gives similar examples:
http://docs.oracle.com/cd/B12314_01/web.904/b10320/genlovw.htm

" As with jsp:include, you can also have an action body with jsp:param tags, as shown in the second of the following examples:

<jsp:forward page="/templates/userinfopage.jsp" />

or:

<jsp:forward page="/templates/userinfopage.jsp" >
<jsp:param name="username" value="Smith" />
<jsp:param name="userempno" value="9876" />
</jsp:forward>"
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, it must do that beneath the covers. Good info.
 
And inside of my fortune cookie was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic