I want to redirect my jsp to another jsp page by using JavaScript function when I open the BeforeLogin
page. But I got below error message.
This error is created because you're calling a JSP that is trying to use Struts tags without having passed through an action first, and hence not finding the required underlying structure.
Struts2 is an MVC framework, which design implies that a new request must pass through a (C)ontroller (the action) and then be rendered through a (V)iew (the JSP).
You must avoid calling JSPs directly, you must instead call the login action, that after its execution will dispatch the login JSP.
window.open("login.action");
Create actionless result and use it instead of JSP.
struts.xml:
<action name="showLogin">
<result>Login.jsp</result>
</action>
JS:
function newpage(){
window.open("showLogin");
}
Explanation:
The error clearly says that
This is usually caused by using Struts tags without the associated filter
it means that you have a JSP and Struts tags inside it, but this JSP is not used by the filter, because it could be a welcome file, i.e. index.jsp
, error code file, i.e. 404.jsp
, configured in the web.xml
.
These resources are handled by the web server before any filter or servlet mapped to the resource is being involved.
Usually welcome files contain a redirect code to a valid action which then dispatch to a JSP that can have Struts tags. Don't use JSPs directly in your application, use actions instead.