Solved

response sendRedirect issue

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now