Solved

problem with sendRedirect() in netscape

Posted on 2001-07-29
10
166 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
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: 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
 
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

DevOps Toolchain Recommendations

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

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 95
micro services vs rest web services 16 103
Spring Framework HTTPSession management 1 33
Custom Java Application connects to database: Which one of the 20? 4 27
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

786 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