Results 1 to 8 of 8
Thread: Java servlet - redirecting url
- 09-21-2012, 02:15 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 1
- Rep Power
- 0
Java servlet - redirecting url
hi , can anyone help me !
I am java beginner ( very new).
I have website http://mywebsite.com ( my html site) and java webpages in http://mywebsite.com/app/index.jsp ( which is my login page)
when I login with user credintials i can see logout (http://mywebsite.com/app/Logout.do) option on right corner when i click on it it is redirecting to again login page . i found that /apps/WEB_INF/LogoutAction class is responsible for this redirection .
Now i want to change the code to redirect it to my html homepage http://mywebsite.com after clicking on logout
LogoutAction.java file is below , please suggest me the appropriate changes for this .
package logout;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LogoutAction extends Action
{
public LogoutAction()
{
}
public ActionForward execute(ActionMapping p_mapping, ActionForm p_form, HttpServletRequest p_request, HttpServletResponse p_response)
{
String target = "login";
p_request.getSession(true).invalidate();
return p_mapping.findForward(target);
}
}
Thank you
- 09-21-2012, 02:53 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
Re: Java servlet - redirecting url
That "login" target will be mapped in the struts xml for the LogoutAction showing where to go.
Change that.Please do not ask for code as refusal often offends.
- 09-21-2012, 06:11 PM #3
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,605
- Rep Power
- 5
Re: Java servlet - redirecting url
Also posted at java servlet- want to redirect to custoem URL
- 10-04-2012, 01:25 PM #4
Member
- Join Date
- Sep 2012
- Location
- Guntur, India
- Posts
- 27
- Rep Power
- 0
Re: Java servlet - redirecting url
You can use
// Throws IOException
[Moderator edit: link removed]try
{
response.sendRedirect("http://mywebsite.com/app/index.jsp");
}catch(Exception e){}Last edited by DarrylBurke; 10-04-2012 at 03:41 PM. Reason: Removed spammy link
- 10-04-2012, 02:17 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
Re: Java servlet - redirecting url
Which would beg the question of why use Struts.
In other words, not a good answer.Please do not ask for code as refusal often offends.
- 10-04-2012, 03:41 PM #6
- 10-19-2012, 05:00 PM #7
Member
- Join Date
- Sep 2012
- Location
- Guntur, India
- Posts
- 27
- Rep Power
- 0
Re: Java servlet - redirecting url
You can set index.jsp in <welcome-file-list> in web.xml after everything.
<welcome-file-list>
http://mywebsite.com/app/index.jsp
</welcome-file-list>
- 10-21-2012, 12:37 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
Similar Threads
-
Redirecting OutputStream to JTextArea
By mellowcandle in forum AWT / SwingReplies: 0Last Post: 05-12-2011, 10:48 AM -
Redirecting Cases in a switch
By rizowski in forum New To JavaReplies: 7Last Post: 03-17-2011, 10:09 AM -
Redirecting output of java program to file
By dewitrydan in forum New To JavaReplies: 4Last Post: 11-17-2010, 06:58 AM -
Problem while redirecting script output to a file using java
By umapathy_sekar in forum Advanced JavaReplies: 4Last Post: 11-09-2010, 09:33 AM -
Need help in redirecting to a url
By umapathy_sekar in forum Advanced JavaReplies: 1Last Post: 09-27-2010, 12:52 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks