• 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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the bellowed prg i am passing x,y into next page by 2 ways.
which one is the best and why?

test1.jsp
---------
<%
String str="test2.jsp?x=20&y=30";
%>
<jsp:forward page="<%=str%>" />


test1.jsp
---------
<jsp:forward page="test2.jsp" >
<jsp aram name="x" value="20" />
<jsp aram name="y" value="30" />
</jsp:forward>
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Venu,

I think the second option is good.

Because instead of using scriptlet, it is good to go for Jsp Elements.Thats what I guess.

Thanks,
Chandra
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Avoid using scriptlet in your jsp page. Avoid as much as you can.

Without scriptlet your jsp would be more readable, simple, and understandable to everyone.
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also works (at least in Tomcat):

<jsp:forward page="test2.jsp?x=20&y=30"/>

-Yuriy
 
Sheriff
Posts: 67749
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
I would avoid hard-coding the URL, whether you use scriptlets or not. Using the JSP actions ensure not only that your URL is correctly formatted, it also URL-encodes the parameter values as necessary.
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic