Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp forward

 
pippiri venu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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>
 
shekar march chandra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • 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.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also works (at least in Tomcat):

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

-Yuriy
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic