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

x
?
Solved

response sendRedirect issue

Posted on 2014-04-29
5
Medium Priority
?
688 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
[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
5 Comments
 
LVL 20

Accepted Solution

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

Assisted Solution

by:rrz
rrz earned 400 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 36

Assisted Solution

by:mccarl
mccarl earned 200 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

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

705 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