Solved

response sendRedirect issue

Posted on 2014-04-29
5
661 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 95
Java Jpanels and Jframe 8 32
oracle 11g 23 77
hibernate example issues from command prompt 10 40
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

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