Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
supriti konda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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.
 
louise rochford
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Hi louise,

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

Thanks.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried google!

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

Cheers
 
suprita konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for All.
I tried to use URLConnection and it is working fine. Finally I solved my problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!