Solved

response sendRedirect issue

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

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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

623 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