struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sriharsha.chev...@wachovia.com
Subject Usage of Struts - Tiles using tile controllers (After i tried using the link provided)
Date Tue, 20 Feb 2007 22:56:56 GMT
Hi Dave,

Thanks for pointing me towards the link, it was of great help. Here is 
what i did. And i am also pasting the error i am getting.

Step1: I created the following definition in my tiles-defs.xml

tiles-defs.xml

<tiles-definitions>
    <definition name="base.page" path="/pages/entCounsTileLayout.jsp">
                <put name="header" value="/pages/entCslHeader.jsp" />
                <put name="contact" value="/pages/contact.jsp" /> 
                <put name="footer" value="/pages/seminarFooter.jsp" />
        </definition>
 
    <definition name="question1.page" extends="base.page">
                <put name="body" value=".question1Body.page" />
        </definition>
<definition name=".question1Body.page" path="/pages/question1Body.jsp" 
controllerClass="com.wef.seminar.entrance.QuestionController">
        </definition>
</tiles-definitions>


Step2: I have the code of the controller i wrote, i have the package 
specific code and import statements intact:

public class QuestionController implements Controller {

        public void execute(ComponentContext context, HttpServletRequest 
request,
                        HttpServletResponse response, ServletContext 
servContext) throws Exception {
        }

        public void perform(ComponentContext context, HttpServletRequest 
request,
                        HttpServletResponse response, ServletContext 
servContext)
                        throws ServletException, IOException {
                java.util.ArrayList q1Choice = null;
                com.wef.seminar.entrance.EntranceAnswers ans = new 
com.wef.seminar.entrance.EntranceAnswers();
                q1Choice = ans.getQ1ChoiceList();
 
                System.out.println("\n************I am 
here***********\n");
                request.setAttribute("q1Choice", q1Choice);
                request.setAttribute("vartest","Ajay Shenoy");
                System.out.println("\n************I end 
here***********\n");
        }

}

Step3: Here is the code of jsp, i.e. question1Body.jsp as mentioned in the 
tiles-defs.xml in the directory "pages".

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<html:html>
        <HEAD>
        <%@ page language="java" contentType="text/html; 
charset=ISO-8859-1"
                pageEncoding="ISO-8859-1" import="java.util.Enumeration"%>
        <META http-equiv="Content-Type" content="text/html; 
charset=ISO-8859-1">
        <META name="GENERATOR" content="IBM Software Development Platform"
>
        <META http-equiv="Content-Style-Type" content="text/css">
        <LINK href="theme/elstylesheet.css" rel="stylesheet" type=
"text/css">
        <TITLE></TITLE>
        <html:javascript formName="AnswerForm" />
        </HEAD>
<BODY>
<html:form action="/question1Action" onsubmit="return 
validateAnswerForm(this)">
 
                          <tiles:useAttribute name="q1Choice" id=
"q1Choice" classname="java.util.ArrayList" scope="request"/> 
                                        <logic:iterate id="row" name=
"q1Choice">
                                                <html:radio property=
"answer" value="value" idName="row"/> 
                                                <bean:write name="row" 
property="label"/> 
                                                <BR>
                                        </logic:iterate>
 
                                        <BR>
                                        <html:hidden property=
"QuestionNumber" value="Question1"/> 
                                        <html:submit property="submit" 
value="Continue" />


</html:form>
</BODY>
</html:html>

Step4: Here is the error i am getting:

Feb 20, 2007 2:42:40 PM org.apache.catalina.core.ApplicationDispatcher 
invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Error - tag useAttribute : attribute 
'q1Choice' not found in context. Check tag syntax
        at org.apache.struts.tiles.taglib.UseAttributeTag.doStartTag(
UseAttributeTag.java:182)
        at org.apache.jsp.pages.question1Body_jsp._jspService(
question1Body_jsp.java:223)
        at org.apache.jasper.runtime.HttpJspBase.service(
HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:334)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(
JspServlet.java:314)
        at org.apache.jasper.servlet.JspServlet.service(
JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(
ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(
ApplicationDispatcher.java:574)
        at org.apache.catalina.core.ApplicationDispatcher.include(
ApplicationDispatcher.java:499)
        at org.apache.jasper.runtime.JspRuntimeLibrary.include(
JspRuntimeLibrary.java:966)
        at org.apache.jasper.runtime.PageContextImpl.doInclude(
PageContextImpl.java:631)
        at org.apache.jasper.runtime.PageContextImpl.include(
PageContextImpl.java:625)
        at sun.reflect.GeneratedMethodAccessor241.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.struts.tiles.TilesUtilImpl.doInclude(
TilesUtilImpl.java:126)
        at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:149)
        at org.apache.struts.tiles.taglib.InsertTag.doInclude(
InsertTag.java:761)
        at 
org.apache.struts.tiles.taglib.InsertTag$InsertHandler.doEndTag(
InsertTag.java:893)
        at org.apache.struts.tiles.taglib.InsertTag.doEndTag(
InsertTag.java:462)
        at 
org.apache.jsp.pages.entCounsTileLayout_jsp._jspx_meth_tiles_insert_1(
entCounsTileLayout_jsp.java:170)
        at 
org.apache.jsp.pages.entCounsTileLayout_jsp._jspx_meth_html_html_0(
entCounsTileLayout_jsp.java:111)
        at org.apache.jsp.pages.entCounsTileLayout_jsp._jspService(
entCounsTileLayout_jsp.java:66)
        at org.apache.jasper.runtime.HttpJspBase.service(
HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:334)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(
JspServlet.java:314)
        at org.apache.jasper.servlet.JspServlet.service(
JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(
ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(
ApplicationDispatcher.java:463)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(
ApplicationDispatcher.java:398)
        at org.apache.catalina.core.ApplicationDispatcher.forward(
ApplicationDispatcher.java:301)
        at org.apache.struts.action.RequestProcessor.doForward(
RequestProcessor.java:1054)
        at org.apache.struts.tiles.TilesRequestProcessor.doForward(
TilesRequestProcessor.java:292)
        at 
org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(
TilesRequestProcessor.java:268)
        at 
org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(
TilesRequestProcessor.java:367)
        at org.apache.struts.action.RequestProcessor.processForward(
RequestProcessor.java:548)
        at org.apache.struts.action.RequestProcessor.process(
RequestProcessor.java:209)
        at org.apache.struts.action.ActionServlet.process(
ActionServlet.java:1858)
        at org.apache.struts.action.ActionServlet.doPost(
ActionServlet.java:459)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java:869)
        at 
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Feb 20, 2007 2:42:40 PM org.apache.catalina.core.ApplicationDispatcher 
invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Error - tag useAttribute : attribute 
'q1Choice' not found in context. Check tag syntax
        at org.apache.struts.tiles.taglib.UseAttributeTag.doStartTag(
UseAttributeTag.java:182)
        at org.apache.jsp.pages.question1Body_jsp._jspService(
question1Body_jsp.java:223)
        at org.apache.jasper.runtime.HttpJspBase.service(
HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:334)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(
JspServlet.java:314)
        at org.apache.jasper.servlet.JspServlet.service(
JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(
ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(
ApplicationDispatcher.java:574)
        at org.apache.catalina.core.ApplicationDispatcher.include(
ApplicationDispatcher.java:499)
        at org.apache.jasper.runtime.JspRuntimeLibrary.include(
JspRuntimeLibrary.java:966)
        at org.apache.jasper.runtime.PageContextImpl.include(
PageContextImpl.java:602)
        at org.apache.struts.tiles.TilesUtilImpl.doInclude(
TilesUtilImpl.java:135)
        at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:149)
        at org.apache.struts.tiles.taglib.InsertTag.doInclude(
InsertTag.java:761)
        at 
org.apache.struts.tiles.taglib.InsertTag$InsertHandler.doEndTag(
InsertTag.java:893)
        at org.apache.struts.tiles.taglib.InsertTag.doEndTag(
InsertTag.java:462)
        at 
org.apache.jsp.pages.entCounsTileLayout_jsp._jspx_meth_tiles_insert_1(
entCounsTileLayout_jsp.java:170)
        at 
org.apache.jsp.pages.entCounsTileLayout_jsp._jspx_meth_html_html_0(
entCounsTileLayout_jsp.java:111)
        at org.apache.jsp.pages.entCounsTileLayout_jsp._jspService(
entCounsTileLayout_jsp.java:66)
        at org.apache.jasper.runtime.HttpJspBase.service(
HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:334)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(
JspServlet.java:314)
        at org.apache.jasper.servlet.JspServlet.service(
JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(
ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(
ApplicationDispatcher.java:463)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(
ApplicationDispatcher.java:398)
        at org.apache.catalina.core.ApplicationDispatcher.forward(
ApplicationDispatcher.java:301)
        at org.apache.struts.action.RequestProcessor.doForward(
RequestProcessor.java:1054)
        at org.apache.struts.tiles.TilesRequestProcessor.doForward(
TilesRequestProcessor.java:292)
        at 
org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(
TilesRequestProcessor.java:268)
        at 
org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(
TilesRequestProcessor.java:367)
        at org.apache.struts.action.RequestProcessor.processForward(
RequestProcessor.java:548)
        at org.apache.struts.action.RequestProcessor.process(
RequestProcessor.java:209)
        at org.apache.struts.action.ActionServlet.process(
ActionServlet.java:1858)
        at org.apache.struts.action.ActionServlet.doPost(
ActionServlet.java:459)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java:869)
        at 
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Feb 20, 2007 2:42:40 PM 
org.apache.struts.tiles.taglib.InsertTag$InsertHandler doEndTag
SEVERE: ServletException in '/pages/question1Body.jsp': Error - tag 
useAttribute : attribute 'q1Choice' not found in context. Check tag syntax
org.apache.jasper.JasperException: Exception in JSP: 
/pages/question1Body.jsp:90

87:                                     and then i am here
88:                                     <BR>
89: 
90:                       <tiles:useAttribute name="q1Choice" 
id="q1Choice" classname="java.util.ArrayList" scope="request"/> 
91:                                     <logic:iterate id="row" 
name="q1Choice">
92:                                             <html:radio 
property="answer" value="value" idName="row"/> 
93:                                             <bean:write name="row" 
property="label"/> 


Stacktrace:
        at org.apache.jasper.servlet.JspServletWrapper.handleJspException(
JspServletWrapper.java:506)
        at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:377)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(
JspServlet.java:314)
        at org.apache.jasper.servlet.JspServlet.service(
JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(
ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(
ApplicationDispatcher.java:574)
        at org.apache.catalina.core.ApplicationDispatcher.include(
ApplicationDispatcher.java:499)

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message