Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > absolute path versus relative path in JSP

Reply
Thread Tools

absolute path versus relative path in JSP

 
 
Matt
Guest
Posts: n/a
 
      07-08-2004
absolute path versus relative path in JSP

I have an index.jsp that will forward to different JSP pages
based on different conditions:

<%
if (cond1)
{
%>
<jsp:forward page="address/page1.jsp"/>
<% }
else if (cond2)
{
%>
<jsp:forward page="address/page2.jsp"/>
<% }
else
{
%>
<jsp:forward page="address/page3.jsp"/>
<% }
%>


The problem is in different pageX.jsp, when user submit form data, it will go to
other pages. Before, the index.jsp is in the same directory as pageX.jsp.
But now I moved out ofthe address folder, and it has broken links.

In my case, should I specify the abosolute path, rather than relative path?
so that in whatever situation, it will work.

please help. thanks!!
 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      07-08-2004
Matt wrote:

> absolute path versus relative path in JSP
>
> I have an index.jsp that will forward to different JSP pages
> based on different conditions:
>
> <%
> if (cond1)
> {
> %>
> <jsp:forward page="address/page1.jsp"/>
> <% }
> else if (cond2)
> {
> %>
> <jsp:forward page="address/page2.jsp"/>
> <% }
> else
> {
> %>
> <jsp:forward page="address/page3.jsp"/>
> <% }
> %>
>
>
> The problem is in different pageX.jsp, when user submit form data, it will go to
> other pages. Before, the index.jsp is in the same directory as pageX.jsp.
> But now I moved out ofthe address folder, and it has broken links.
>
> In my case, should I specify the abosolute path, rather than relative path?
> so that in whatever situation, it will work.


If it is important that the browser know which resource actually
delivers the response (i.e. that the response came from
address/page3.jsp rather than from index.jsp) then you need index.jsp to
redirect instead of forwarding. [response.sendRedirect(...);] In that
case, the browser will resolve URLs relative to address/pageX.jsp
instead of relative to index.jsp, which may solve your problem. Another
alternative would be to put a <base> element in the html <head> of the
response, in which you specifies the correct URL against which to
resolve relative URLs.

If neither of those suggestions is helpful then I guess I don't
understand the problem well enough. A minimal, self-contained example
would illustrate the problem well enough to elicit better targeted
responses.


John Bollinger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Matt
Guest
Posts: n/a
 
      07-08-2004
thanks!!

response.sendRedirect(URL); is working for me now.

One problem though, because there is another jsp page from other
machine that will call index.jsp (other page->index.jsp -> page1.jsp).
And in page1.jsp, it has code: request.getParameter("state");, now the
data is null. But if I use <jsp:forward page="page1.jsp"/>, it can
resolve this problem but it creates the broken link problem.

Are there any workarounds that I can use response.sendRedirect(...)
but still able to pass the data to page1.jsp.

any ideas? thanks!
 
Reply With Quote
 
Sudsy
Guest
Posts: n/a
 
      07-08-2004
Matt wrote:
<snip>
> One problem though, because there is another jsp page from other
> machine that will call index.jsp (other page->index.jsp -> page1.jsp).
> And in page1.jsp, it has code: request.getParameter("state");, now the
> data is null. But if I use <jsp:forward page="page1.jsp"/>, it can
> resolve this problem but it creates the broken link problem.
>
> Are there any workarounds that I can use response.sendRedirect(...)
> but still able to pass the data to page1.jsp.
>
> any ideas? thanks!


Stuff it in the session context and extract accordingly.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one get an absolute absolute file path? James Byrne Ruby 3 09-14-2010 06:02 PM
Relative versus absolute paths on Windows Jason R. Coombs Python 5 11-24-2009 06:02 AM
Re: Mozilla versus IE versus Opera versus Safari Peter Potamus the Purple Hippo Firefox 0 05-08-2008 12:56 PM
How do I convert an absolute path into a relative path Nigel Wilkinson Ruby 2 07-25-2005 07:37 PM
Make a relative url path from an absolute path to another one Thomas Guettler Python 3 10-27-2003 04:41 PM



Advertisments