Solved

problem with sendRedirect() in netscape

Posted on 2001-07-29
10
165 Views
Last Modified: 2013-11-24

hi,

I have the following servlet code

res.sendRedirect("/KrizmMail_S/servlet/KrizmMailServlet?current_folder=inbox");
it is working fine in ie 5.5
but in netscape 4.7  it gives the message
This page has
 moved to <link>here</link>

my system configuration is redhat linux 7.1,apache,tomcat.

plz. help me to solve this problem.

thanx in advance.
merson

0
Comment
Question by:merson
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 15

Expert Comment

by:a.marsh
ID: 6333298
Is everything on the same server?

Are you using SSL with the page?

These are just some of the scenarios when I've had a similar kind of issue.

The only way that I got around it was not to redirect but "connect" directly to the URL using the URLConnection class, reading the response in and then outputting it directly to the browser.

:o)

Ant
0
 
LVL 3

Expert Comment

by:black
ID: 6333309
it happens because the response.sendRedirect method sends a response back to the browser requesting it to go to another url. You should be able to change the configuration on the browser so it follows redirects. I know it's a setting in IE but I'm not sure about Netscape
0
 

Author Comment

by:merson
ID: 6333311

hi marsh,

i have everything ( servlets,html files, images...)
on the same server.
and it works fine with ie 5.5.

could u plz. give me details of the code u suggested


merson
0
 
LVL 3

Expert Comment

by:dnoelpp
ID: 6333403
I suggest you to use <jsp:forward> instead. sendRedirect just tells the browser to go to another url. This might not always work. And there are additional round-trips. Like this:

Browser: Give me http://www.yourserver.com.
Server:  Please read http://www.yourserver.com/index.html instead.
Browser: Give me http://www.yourserver.com/index.html.

You get the picture? <jsp:forward> however just gives the other file immediately.

If you work with servlets use this instead (does the same):

getServletContext().getRequestDispatcher(otherUrl).forward(request, response);
0
 
LVL 3

Expert Comment

by:black
ID: 6334211
you cannot forward to a page that is not on your webapp i.e. if you have a webapp called "myWebApp" which maps to the following url
/myWebApp
on your App Server, you cannot redirect to
"http://blah.com"
you can only redirect or forward to resources within "myWebApp"
for example if you did
getServletContext().getRequestDispatcher("/index.html").forward(request, response);
it actually maps to
/myWebApp/index.html

you could do that and simply have a meta tag in that file which tells the browser to redirect to another page, or have some java script but either way you've got to tell the browser what to do.

Ant's way would work but with issues.
Basically you can create a new URL to the place you want and download the content but reading it's input stream and then writing the content back to the browser. But if it has any relative links to images, or other pages they will be intepreted by the browser relative to your url therefore unless you modify each of those links any relative images and anchors will be broken. I did some work on doing this exact same process and had to parse the entire input as an XML document and modify all anchor, image, base, etc... tags that had any relative links. If it has javascript to create links then it's pretty much impossible.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Expert Comment

by:dnoelpp
ID: 6334248
Yes, you are right. I just assumed the page merson wanted to redirect to is on the same web application.

/KrizmMail_S/servlet/KrizmMailServlet?current_folder=inbox definitively looks like being on the same web app. Or am I mistaken?
0
 

Author Comment

by:merson
ID: 6334270
thanx guys

i want to redirect to the same webapplication itself

merson
0
 

Author Comment

by:merson
ID: 6334309

hi,

i hust changed the code
from

res.sendRedirect("/KrizmMail_S/servlet/KrizmMailServlet?current_folder=inbox");

 to

res.sendRedirect("/KrizmMail_S/servlet/KrizmMailServlet");


now it is working.

but don't know what went wrong  in the first case


merson
0
 
LVL 3

Expert Comment

by:dnoelpp
ID: 6334316
Really strange, huh? :-)
0
 
LVL 3

Accepted Solution

by:
black earned 200 total points
ID: 6336205
I think it's because you had parameters in the first instance and Netscape wanted confirmation before a url was called with parameters. I believe it's for security so the user doesn't unwittingly submit data and are not aware of it.
It probably is better for you to forward it causes less network traffic, and it's done on the server side so it's guaranteed to work always.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 86
reasons why a "inside Menu" would not appear for a web server 6 56
Where to store the queries for modification of table 4 55
GUI builder for Eclipse? 8 27
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now