Solved

response sendRedirect issue

Posted on 2014-04-29
5
672 Views
Last Modified: 2014-04-30
I have a web app .  name :  PaymentServices.war


I want to redirect to   url http://localhost:8080/PaymentServices/index.action  as soon as browser's welcome page is hit .



I am confused which one to  write in welcome.jsp  . This is default welcome page.



<%
  response.sendRedirect("index.action?lang=en");
%>


OR


<%
  response.sendRedirect("/index.action?lang=en");
%>

OR

<%
  response.sendRedirect("PaymentServices/index.action?lang=en");
%>

OR

<%
  response.sendRedirect("/PaymentServices/index.action?lang=en");
%>

OR

 anything else ?
0
Comment
Question by:cofactor
5 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 350 total points
ID: 40029567
<%
  response.sendRedirect("index.action?lang=en");
%>
0
 
LVL 27

Assisted Solution

by:rrz
rrz earned 100 total points
ID: 40029603
The first and the last in your list will work.
>anything else ?  
If you want to go
>  as soon as browser's welcome page is hit .
then why not change your web..xml to have
 <welcome-file-list>
        <welcome-file>index.action?lang=en</welcome-file>
 </welcome-file-list> 

Open in new window

0
 

Author Comment

by:cofactor
ID: 40031096
>>>hen why not change your web..xml to have

this wont load  struts tag library.

hence I want to route through struts action.
hence I want to do  redirect.
0
 
LVL 35

Assisted Solution

by:mccarl
mccarl earned 50 total points
ID: 40031298
Now I am confused though.. you say
as soon as browser's welcome page is hit
What do you mean by "browsers" welcome page? Did you actually mean "your website" welcome page?

ie. What address are you entering, that you wish to then redirect to your index.action page...

http://localhost:8080/
 ...or...
http://localhost:8080/PaymentServices/

If the second option is what you are after, then as stated above the first or last options you listed can be used in the welcome.jsp file that is part of your .war file.

If you want the first option, then you can add the welcome.jsp file (that contains the redirect as per the last option you listed) to the web containers ROOT. This is probably dependant on the actual container but if you are using Tomcat you can put this file in <Tomcat>/webapps/ROOT (if it doesn't work as welcome.jsp try calling it index.jsp)
0
 

Author Comment

by:cofactor
ID: 40032536
>>Did you actually mean "your website" welcome page?

yes.

first and last option works fine.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 53
ejb wildfly example 2 75
Glassfish admin console not working 1 61
Java: anonymous class 4 39
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

726 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