Click to See Complete Forum and Search --> : JSP - image url for both file system reference & context root reference


log_deepak
08-27-2004, 09:43 PM
Hello,

My name is Deepak. I have a jsp page. I'm including this as part of a screen. I need to show this page both as part of the screen as sand alone.

The problem is:
a)
If I need to show the page as part of the screen(For ex: url: http:\\contextroot\mypagescreen.screen), I have to give the images in the jsp file as <img src=contextroot\Images\image.gif>....

b)
If I need to show the page as standalone(For ex: url: http:\\contextroot\mypage.jsp), I have to give the images in the jsp file as <img src=\Images\image.gif>....

Since my requirement is to show the jsp page as both part of a screen as well as standalone, I'm thinking of having two jsp pages(with same content), one which i will use as part of the screen and another for standalone purposes. The only difference between these two will be that in one I will have the images as <img src=contextroot\Images\image.gif>.... and in the other as <img src=\Images\image.gif>....

However since its the same content, I feel this is not optimized. Can some body help me identify a mechanism in such a way that I can use the same jsp page both as part of a screen as well as stand-alone?

Thanks in advance.
Deepak

Khalid Ali
08-28-2004, 11:39 AM
Your question needs more description....what do you mean by screens...it sounds to me that you are using some type tag lib.
If so then your tag lib should have resoolved to the actual file path in the img tag....point is explain your question and technology u are using in more detail....

log_deepak
08-29-2004, 01:30 AM
Khalid,
Firstly, thank you for your interest.
I'm not using any tag library for this particular page. What I meant by a screen was a web page. I used the pet store framework for web development on Websphere server. According to this, every page in my website can be defined as a "screen". The advantage of this approach is re-usability. i.e I can have the same header, footer as separate jsps and different bodies(separate jsps) and i can combine these into different screens. But in this approach all file paths are to be given with respect to the context root.

I'm using this approach for all web-pages, except one. Here I just have to use the jsp directly, no header footer, etc is needed on this page. I was thinking that instead of defining a separate screen for this, I can call the jsp directly. But if i use a stand-alone jsp, then the file paths must be given with reference to the file system path.

So i was wondering if there will be a approach by which i can define file paths in my jsp, such that it is recognized both w.r.t context root as well as file system path.

Hope the picture is clearer now, Khalid.

Thanks,
Deepak

Khalid Ali
08-29-2004, 06:10 PM
sorry...but it still is confusing...context root does not have anything to do with your web pages,once a context root is set in your application/web server,then when you prepend that context root value with any resources, server automatically resolves that path..
however since I am not familiar with Websphere environment...I can not say how it works...what I have said above is typical and it works with mostservers( weblogic and any other web/app server)...
Point is if you have context set correctly,then any jsp page or any other resource for that context should be visible for all pages....