Link to home
Start Free TrialLog in
Avatar of umajava
umajava

asked on

url redirection

Hi,
If I enter http://localhost:8080/mypage/index.jsp,

I need to redirect the user to http://mywebsite/mypage/index.jsp

I made changes to the web.xml file to add servlet and servlet-mapping, but it wont work. Any work arounds?

Uma
Avatar of sompol_kiatkamolchai
sompol_kiatkamolchai
Flag of Thailand image

just replace content of index.jsp in localhost to

<%
response.sendRedirect("http://mywebsite/mypage/index.jsp");
%>
Avatar of kiranhk
kiranhk

you can use any of these in your index.jsp

<META HTTP-EQUIV="REFRESH" content="0; url=http://xxx.com">

or

<jsp:forward page='http://xxx.com/xyz/test1.jsp' />
Avatar of umajava

ASKER

Hi,
Thanks for replies. If I need to do the above mentioned ways, I need to change lot of code, Instead can't we do this in web.xml file?

I only wanted to replace the :8080 port with "" (empty string).

e.g http://mywebsite:8080/mypage/index.jsp to be redirected to
http://mywebsite/mypage/index.jsp

Any ideas?
imho , i dont think so. when u dont mention port it tries default port of 80.you can configure weblogic proxy server to listen requests at port 80 and forward all request to your web application server. try virtual hosts maybe then can help
Avatar of umajava

ASKER

any ideas on how to do this technically?
If you specify different port number, that mean you point to different web application. In web.xml file you can mapping url-pattern only in the same web application.

I'm very quite sure that we can only redirect the request to the target web application by using first and second comment.

Best luck,
Avatar of umajava

ASKER

Hello,
I am very confused with your last comment, If I enter
http://myhost:8080/mypage.jsp, I am intending to see mypage.jsp in the same app.

Now lets say that the default port that is served for myhost is 80, but the user has typed 8080 port in the address bar, so there is no app running on 8080 port, this is understood by the server and displays cannot find server.

Instead cant we do a redirect in the server itself to 80 port?
thats why you have to use a proxy.
check out weblogic docs to find out how to configure a proxy.
it is nothing but another managed server starting up with root previliges , it will have 2 servlet httpclusterservlet and fileservlet .
map all httpclusterservlet traffic to your web application servlet.
its all in the docs.
ASKER CERTIFIED SOLUTION
Avatar of sompol_kiatkamolchai
sompol_kiatkamolchai
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial