Solved

problem with sendRedirect() in netscape

Posted on 2001-07-29
10
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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 if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

630 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