• 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

absolute URL path problem in jsp:forward ... tag

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to forward the page using absolute URL. The problem is it is appending the "/" infront of
http://xxx.com/test1.jsp i.e if the url becomes /http://xxx.com/xyz/test1.jsp if use forward tag in jsp.
Why is that forward slash ("/") appending to the URL?
Please can any one know why I have this problem.
Here is the code I am using:

test.jsp:
****************
<html>
<body>
<jsp:forward page='http://xxx.com/xyz/test1.jsp' />
</body>

Thanks.
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Supriti,

According to the jsp spec...

The <jsp:forward> element forwards the request object containing the client request information from one JSP page to another resource. The target resource can be an HTML file, another JSP page, or a servlet, as long as it is in the same application context as the forwarding JSP page.



So if xyz is the web app of test.jsp, you can forward to test1.jsp with
<jsp:forward page="test1.jsp" />, and the slash gets prepended to your 'goto' page.

If test1.jsp is in another web app, I think you're out of luck with jsp:forward - try c:inport instead if that is available to you.

Regards,
Louise
 
supriti konda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Louise,

Here is my problem:

I need to forward jsp page to read CGI Report which is running on same server (the folder of jsp pages and CGI pages are diff on the same server).
I don't have any control on CGI page. If I use response.sendRedirect() method works fine but the problem is if I copy that CGI report URL from current browser to new browser it still works. My prob is it should not work when user copy the URL from current browser to new browser. ( I don't have any control on CGI report). Why I am trying to use forward is user can't see the URL in browser.
How can I solve my problem?
Any help please... I am struggling lot with this.

Thanks.
 
Sheriff
Posts: 67746
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
You can't use forward for that. Set up your app for the JSTL and use <c:import> as louise suggested.
 
louise rochford
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mmmm, stretching my knowledge a bit here as I don't really know much about CGI. At a guess, I'd say there are 2 options:

1) Embed the CGI-produced page within a jsp. You need to have JSTL available to do this.
<html>
<body>
<c:import page="http://xxx.com/xyz/test1.jsp" />
</body>

OR
2) Use response.sendRedirect(), but send it to some CGI component that you don't mind people seeing the address for, & get that component to pass the request on to 'test1.jsp'. I don't know how feasible this is though.

Regards,
Louise
 
supriti konda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi louise,

I am not that much familiar with JSTL. Do you have any sample code?

Thanks.
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried google!

Here's a page with some code showing usage of c:import

Cheers
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for All.
I tried to use URLConnection and it is working fine. Finally I solved my problem.
 
A berm makes a great wind break. And we all like to break wind once in a while. Like 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