Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Struts2: How do I tell my index.jsp to forward to a struts2 action?

Oftentimes when I see an index.jsp on a web application it just forwards to another url like login.jsp such as

<jsp:forward page="login.jsp" />

When using struts2, I want a similar index.jsp but I want it to forward to an action. How do I do this?

like image 451
avendael Avatar asked Dec 02 '22 05:12

avendael


2 Answers

You can use plain HTML if you want

Between your head tags use:

 <META HTTP-EQUIV="Refresh" CONTENT="1;URL=Login.action">

This will redirect to myCOntext/Login.action

If Login is behind a name space you wil need to include that in the URL

like image 50
Allan Avatar answered Dec 06 '22 10:12

Allan


Scriplet:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<%  
response.sendRedirect("/Project/namespace/Login.action");
%> 

I use it with Struts2 and it works.

like image 31
Trick Avatar answered Dec 06 '22 10:12

Trick