Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

problem with sendRedirect() in netscape

Posted on 2001-07-29
10
Medium Priority
?
173 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
Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

 
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 800 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

670 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