This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Help me on URL issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help me on URL issues" Watch "Help me on URL issues" New topic
Author

Help me on URL issues

Mohammad Norouzi
Ranch Hand

Joined: Jul 12, 2005
Posts: 71
Hi

I have a servlet in which some part of my page will be displayed by sending a http request to another application (in different context).

Consider this content includes some images and styles and also some hyper links.

I want every hyper links being served through my own servlet. In order to do this, I wrote a filter to manage them.

But the problem is with resources like images. I want to load those resources from their own path. Could you help me how can I do that?

I saw many web applications that bring images and resources from other hosts and applications. Could you please give me an idea on this?


Regards, Mohammad
my.blog | my.photoblog | Add your name to SCJP Wall Of Fame
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

the question is very confusing to me ( you tried to mention amnay things at a time)

Anyways as far as i understand , for your problem
I would prefer using Jsp Frames .


Save India From Corruption - Anna Hazare.
Mohammad Norouzi
Ranch Hand

Joined: Jul 12, 2005
Posts: 71
Thanks for your reply.

Let me explain with example. I have an application namely APP1 which is my own application:

http://www.server.com/myapp

in this app, I have a frame or DIV or anything to divide contents. A menu and a content. Menus contains some parameters and when user clicks on an item I build a request to another app namely APP2:

http://www.server.com/otherapp/store.jsp?q=value1

Then I obtain the result from above path and display it in content frame. Now this content contains images and links. but images refer to another path that doesn't exist in my application and they belong to APP2:

<img src="/images/logo.gif" />

and

<a href="/pages/show.jsp" >Show</a>

since these paths are relative the browser adds the context path to them (http://www.server.com/myapp)

I want to rewrite the image sources in a way yo refer to an absolute path which refers to real application like:

<img src="http://www.server.com/otherapp/images/logo.gif" />

but for the links, I dont want to change them because I already manage them with servlet filters.

how can I rewrite image sources?

thanks

Ravi Kiran Va wrote:the question is very confusing to me ( you tried to mention amnay things at a time)

Anyways as far as i understand , for your problem
I would prefer using Jsp Frames .

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

but for the links, I dont want to change them because I already manage them with servlet filters.


How did you manage to do for the Links <a href="/pages/show.jsp" >Show</a> , how did you find out how many link tags are present in that Html or Jsp page ??


Mohammad Norouzi
Ranch Hand

Joined: Jul 12, 2005
Posts: 71
I find them when user clicks on that... so I can forward the request to a specific path

Ravi Kiran Va wrote:
but for the links, I dont want to change them because I already manage them with servlet filters.


How did you manage to do for the Links <a href="/pages/show.jsp" >Show</a> , how did you find out how many link tags are present in that Html or Jsp page ??


Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

To be frank , i dont know the answer for your question

Why i asked for the links is that , how did you manage to read how many <href> tags are present in your Jsp page , so to append some url to the existing thing .

Anyway , i will proceed in this below mentioned way and hope for the best :

On to the Jsp / Html Page i will read all the Image Tgas using Dom API on to a body onload Java Script function and for each source attribute , i would add this http://www.server.com/myapp
to the existing value .

Hope this could help you , but i am not sure if this is the way to do it .

Thanks .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help me on URL issues
 
Similar Threads
Add items in Drop Down List from a child window to parent window.
going nuts trying to reference images on server
Is it possible to save the data of the applet when focus is lost from it
Cannot pass parameter to Servlet?
Want to include html in my email message...