sufiyan ali
sufiyan ali

Reputation: 71

org.apache.tiles.util.TilesIOException: JSPException including path '/login.jsp'

I m new to tiles and strut2. I am not able to understand that when I use the HTML tag in login.jsp page then it works fine but at the same time if I code in struts tag in login.jsp then it gives an error. why this is happening I am not able to understand. The following code and error are given below ..kindly help me

HTTP Status 500 - Internal Server Error

type Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error executing tag: JSPException including path '/baseLayout.jsp'.

root cause

org.apache.tiles.TilesException: JSPException including path '/baseLayout.jsp'.

root cause

org.apache.tiles.util.TilesIOException: JSPException including path '/baseLayout.jsp'.

root cause

org.apache.tiles.util.TilesIOException: JSPException including path '/login.jsp'.

root cause

The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1 logs.

web.xml

  <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://java.sun.com/xml/ns/javaee" 
   xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   id="WebApp_ID" version="2.5">
   <display-name>Struts2Example15</display-name>
    
   <context-param>
   <param-name>
      org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
   </param-name>
   <param-value>
      /WEB-INF/tiles.xml
   </param-value>
   </context-param>

   <listener>
   <listener-class>
      org.apache.struts2.tiles.StrutsTilesListener
   </listener-class>
   </listener>

    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
   
   <filter>
   <filter-name>struts2</filter-name>
   <filter-class>
   org.apache.struts2.dispatcher.FilterDispatcher
   </filter-class>
   </filter>

   <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
   </filter-mapping>

   
</web-app>

struts.xml

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
 
    <!-- Configuration for the default package. -->
    <package name="default" extends="struts-default">
        <result-types>
            <result-type name="tiles" class="org.apache.struts2.view.tiles.TilesResult"/> 
            </result-types>  
        <action name="loginAction" class="package_entry.loginAction" method="execute">
            <result name="getin">welcome.jsp</result>
             <result name="user_login">user_login.jsp</result>
        
        </action>

    </package>
</struts>

index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
        <%@page language="java"%>
    <%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
    <tiles:insertTemplate template="/baseLayout.jsp">
        <tiles:putAttribute name="tiles" value="this is tes framework" type="string"/> 
            <tiles:putAttribute name="header" value="/header.jsp" /> 
            <tiles:putAttribute name="menu" value="/menu.jsp" /> 
            <tiles:putAttribute name="body" value="/body.jsp" /> 
            <tiles:putAttribute name="footer" value="/footer.jsp" />   
    </tiles:insertTemplate>

menu.jsp

<%@taglib uri="/struts-tags" prefix="s"%>
<a href="loging.jsp">Login</a><br>
<a href="registring.jsp">Register</a><br>
<a href="contacting.jsp">Contact</a><br>

loging.jsp

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="login.def"/>

tiles.xml

<tiles-definitions>
 
<definition name="baseLayout" template="/baseLayout.jsp">
<put-attribute name="title"  value="Template"/>
<put-attribute name="header" value="/header.jsp"/>
<put-attribute name="menu"   value="/menu.jsp"/>
<put-attribute name="body"   value="/body.jsp"/>
<put-attribute name="footer"   value="/footer.jsp"/>
</definition>
 
<definition name="login.def" extends="baseLayout">
<put-attribute name="title"  value="Login form"/>
<put-attribute name="body"   value="/login.jsp"/>
</definition>
 
<definition name="register.def" extends="baseLayout">
<put-attribute name="title"  value="Register"/>
<put-attribute name="body"   value="/register.jsp"/>
</definition>
 
<definition name="contact.def" extends="baseLayout">
<put-attribute name="title"  value="contact"/>
<put-attribute name="body"   value="/contact.jsp"/>
</definition>
 
</tiles-definitions>

login.jsp

<%@taglib uri="/struts-tags" prefix="s"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <s:form>
            <s:textfield name="email_id" label="Email"/>
            <s:password name="password" label="Password"/>
            <s:submit value="login"/>
        </s:form>
    </body>
</html>

Upvotes: 2

Views: 14944

Answers (1)

QGA
QGA

Reputation: 3192

Most probably you have to add the relative path to each definition

For instance change

value="/login.jsp"/>

in

value="/WEB-INF/path/to/your/login.jsp"/>

Therefore:

<definition name="login.def" extends="baseLayout">
   <put-attribute name="title"  value="Login form"/>
   <put-attribute name="body"   value="/WEB-INF/path/to/your/login.jsp"/>
</definition>

In addition I do not see anywhere your tile render and configurer. Have you added tiles into your pom?

Upvotes: 0

Related Questions