aspose file tools*
The moose likes JSP and the fly likes Redirects in the JSP 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
Bookmark "Redirects in the JSP" Watch "Redirects in the JSP" New topic
Author

Redirects in the JSP

Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
Hi,

I am running a jsp on websphere 6.1. The jsp has the image link which automatically redirects to the other domain. However if I load the JSP on the server, redirect doesn't work. If I put I put the code in plain html page it wors perfectly fine.

In this example if I open the image link https://c.xxx.com/ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0 it get redirects to
https://c.yyy.com/ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0 and image get loaded.
If I run the below html, it also loads the image with internal redirect to link on the domain c.yyy.com. However, when I put this code in JSP and run on the server, the redirect doesn't work and the image is broken. Can someone please advise why this doesn't work on server and what fix needs to be applied?



Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Do a View Source at the browser and compare the image link that works to the one that doesn't.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
Hi,
Thanks for your input. Actually I created the html from the view source of the jsp page. Jsp doesn't work but html.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

If they are identical, they will work identically.
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
Ideally it should work identical.
When I open the html in the browser on my desktop. It redirect correctly. However, when I put the html on server and run it, it doesn't.
What could be the issue on the server that it is not allowing to redirect the image URL?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

It's hard to understand your wording, but do I understand that you are asking about some kind of redirect which is taking place on the server, and you are showing us some HTML which would therefore have nothing to do with that?

I ask because you seem to be talking about running HTML on the server -- I can't figure out what that means.
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
1. The redirect is configured on the server for the link https://c.xxx.ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0 to https://c.yyy.ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0.
If I directly open the https://c.xxx.ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0 in browser it goes to later.
2. The links above are from different server than my websphere server I am running the html on.
I am expecting the html execute on my websphere server which contains the above link and should redirect to c.yyy.... as it redirects in bullet 1 above.

3. If I open the html locally (not on the server), the redirect works in html.

Does this explain the issue?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Amit K Jain wrote:1. The redirect is configured on the server


Configured on the server? What does that mean?
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
This is a third party link and not from the websphere server I am using. For some reason they wanted to change the domain from c.xxx to c.yyy. Somehow they managed to send the request from xxx to yyy. Due to this change, since my application has the link for 'xxx' and it is not redirecting as explained above, appearing as broken.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Amit K Jain wrote:and it is not redirecting as explained above


Okay. If you want to get out of explaining by claiming you already did, that's fine. Good luck with your project.
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
Hey, I am bit confused now. I am explaining everything and answering question to get the solution for my issue. This is midnight here still I am up to give the information you are asking for, just to get the resolution because it's MY need. What did make you think that I don't want to explain? If I don't explain the issue I will not get the right answer that I well aware off.

Just to avoid the repetition I said 'as explained above'. Sorry for any mis-understanding.


1. The redirect is configured on the server for the link https://c.xxx.ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0 to https://c.yyy.ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0.
If I directly open the https://c.xxx.ImageServer?oid=00D30000000MODz&id=01530000001J0HYAA0 in browser it goes to later.
2. The links above are from different server than my websphere server I am running the html on.
I am expecting the html execute on my websphere server which contains the above link and should redirect to c.yyy.... as it redirects in bullet 1 above.

3. If I open the html locally (not on the server), the redirect works in html.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Paul Clapham wrote:
Amit K Jain wrote:1. The redirect is configured on the server


Configured on the server? What does that mean?


So I asked you this. And you responded by not answering it, but by copying your original post. Let me try asking it in a different way, then. Exactly what did you do to configure the redirect on your server? Hopefully if you answer that, it might go some way toward explaining what "configured on the server" actually means.
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
These links are from third party environment (Salesforce). I do not have the control over it, hence I am really not aware of it.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Okay. Then if you don't know what they did, and it's a problem, and you can't explain it to anybody, then the best approach would be to ask them to deal with the problem. Let's carry on with this one instead:

Amit K Jain wrote:3. If I open the html locally (not on the server), the redirect works in html.


That sounds like you're "opening the HTML on the server". What exactly does that mean? It sounds like you are signing on to the machine where the server is running and opening a browser. Is that right?
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
It means I have a html on my desktop and I opened it in the browser as a file. It works i.e. the image link redirects correctly
e.g. d:\\page.html

Another scenario was I push the same html on the websphere server and run it, the image link doesn't redirect and hence appears as broken.
e.g http:\\localhost:9080\context\page.html
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

If I read what you didn't write there... in the first case you loaded a page into a browser on your computer, which isn't the Websphere server. And in the second case you loaded a page into a browser on some other computer, which is the Websphere server.

And in the first case, a certain link worked correctly in that it connected to a particular server, which then asked for a redirect. Whereas in the second case, that link "didn't work". Either because it couldn't connect to that particular server, or that it didn't receive a redirect request from that server, or that it didn't handle the redirect request correctly, or that it couldn't connect to the server named in the redirect request.

So I don't see a problem here. Nobody is going to be using a browser on the actual Websphere server anyway, so its behaviour is immaterial.

However perhaps I guessed incorrectly at what you didn't write.
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55

Whereas in the second case, that link "didn't work". Either because it couldn't connect to that particular server, or that it didn't receive a redirect request from that server, or that it didn't handle the redirect request correctly, or that it couldn't connect to the server named in the redirect request.


Possibly the reason could be any of you listed.
I realized that the difference between working and non working scenario is the 'websphere server'

I was in the impression that I might be missing something on my server, hence posted the question here. If you can advise if there is any way we can make the server talking to third party instance so that redirect works will be helpful.
I will shoot this question to Salesforce too if they have to say anything on this.

Thanks
Amit
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Amit K Jain wrote:If you can advise if there is any way we can make the server talking to third party instance so that redirect works will be helpful.


I don't think there's any point. In real life nobody ever signs on to the machine with the server and runs a browser there, so if your links don't happen to work in just that scenario, it isn't worth fixing that.

Of course that's still under the assumption that signing on to the server machine and running a browser there is actually the scenario you're asking about. So far your description of the problem could be describing that scenario but it could also be describing a variety of other scenarios too. But you haven't ever given a precise description of the scenario you're talking about. Instead we just get vague phrases like "server talking to". And you haven't even responded to my guesses about what your scenario might be. So I think we are wasting our time here. You may continue to go on doing so if you like but I have run out of interest.
Amit K Jain
Ranch Hand

Joined: Nov 06, 2008
Posts: 55
Its my bad if I still could not explain the issue.
Just wanted to add on your recent comment: If I have deployed any web application on the server (here websphere), the web pages of that application can be accessed in the browser from any machine as long as the server is up and running. It is not necessary that I need to log in to the server, the application is deployed on. It's just a web application.

I gave you the sample link as http:\\localhost:9080\context\page.html because I am running the application on my local server which is built in my IDE. If I have to access this page from other machine, I may have to use the IP of my machine like http:\\<ip>\context\html.jsp.


Anyways, thank you for your time on this.

Regards
Amit
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Redirects in the JSP