File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes jsp forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp forward" Watch "jsp forward" New topic

jsp forward

pippiri venu

Joined: Apr 19, 2005
Posts: 8
in the bellowed prg i am passing x,y into next page by 2 ways.
which one is the best and why?

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

<jsp:forward page="test2.jsp" >
<jsp aram name="x" value="20" />
<jsp aram name="y" value="30" />

venu gopal p
shekar march chandra

Joined: Jul 07, 2005
Posts: 25
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.

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Dec 13, 2004
Posts: 429
Also works (at least in Tomcat):

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

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

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.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: jsp forward
It's not a secret anymore!