File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes relative vs absolute jsp url issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

relative vs absolute jsp url issue

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Hi guys,
I have a j2ee web application with jsp pages. in these pages i use relative paths for some js and css files etc..

my web app talks with an external server . this server asks me to provide a url of a page in my web app where he can send me some sensitive data that i disply in this jsp page.
i provide to external server the absolute path to my page (ex : http://mysite.com/my_page.jsp) i can't provide the external server relative path as he can't understand the relative url i give him.
now inside this 'my_page.jsp' my web app is not able to recognize the relative paths for files it should include 'css/my_css.css' etc..)
I tried to provide full path to these resource files but it seems not to work. i'm calling a javascript function inside this jsp page which is defined in a js file which is also binded with other js files and js libraries like jquey and also the struts libraries etc. it's turning to a mess.

How can i handle this situation? what should i use for relative paths in my_page.jsp which is forwarded by external server ? it seems when external server forward to the absolute url http://mysite.com/my_page.jsp , my_page.jsp is no more aware of the java web app context path. this is my problem and don't know if someone encountered it before.
hope i explained well the problem. and would like some help solving it.

thanks much!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

You talk as if the only possibilities are absolute paths, or page-relative paths. Neither works well.

You should be using server-relative paths -- those that being with the context path.

See the JSP FAQ for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Bear Bibeault wrote:You talk as if the only possibilities are absolute paths, or page-relative paths. Neither works well.

You should be using server-relative paths -- those that being with the context path.

See the JSP FAQ for more information.


thank you for the hint.
the ${pageContext.request.contextPath} solves the problem. however not 100% in my case!
in fact i have a javascript file in which i use and the my_page.jsp is displayed in this jquery pop up ajax dialog when externel server redirect to it.
it seems when i get forwarded by external server to my_page.jsp inside the jquery pop up dialog ;this pop up jquery dialog is no more aware of it's parent web page. for example if i call a method it doesn't work as theis undefined as js tells me.
what could be this problem? why the jquery ajax dialog is no more aware of the parent web page it was called from?

thanks for further assistance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

This latter problem doesn't seem to have anything to do with the first. And certainly has nothing to do with JSP. I'm going to close this topic as resolved and let you open a new topic in the JavaScript forum to deal with the jQuery issue.

You might want to describe the issue a littler better. I'm not getting much from your above post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: relative vs absolute jsp url issue