Win a copy of Functional Reactive Programming this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic

relative vs absolute jsp url issue

 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 65221
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 65221
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic