You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jon Wingfield <jo...@mkodo.com> on 2003/03/04 17:08:57 UTC

Re: Objects in JSP PLEASE HELP.

Given the way your page is currently set up, this should work:

<snip>

EditorContent content = (EditorContent)pageContext.getAttribute("content");

</snip>

I can't remember exactly how the TagExtraInfo stuff works but have a 
look at the compiled jsp (the .java src file) in tomcat's work 
directory. It may have created a variable  EditorContent of type 
boa.EditorContent for you to reference.
The pageContext variable in the above code is an implicit object 
available in the jsp and is the same object you used in the tag. See 
section 2.8.3 of the JSP 1.2 spec for details: 
http://java.sun.com/products/jsp/download.html#specs

Jason Johnston wrote:

>>>>jakerobb@mac.com 02/27/03 02:56PM >>>
>>>>        
>>>>
>Can you show us the errors that were reported when the JSP failed to
>compile?  Full stacktraces are best.
>
>-Jake
> 
> 
>Yes, here they are.  I guess my real problem is that I'm not sure how
>to reference the object from the page.
>All the errors and source code are below.  Thanks.
> 
>*************************************************************************************************************************
>***  tomcat log
>*************************************************************************************************************************
> 
>2003-02-28 09:37:58 ApplicationDispatcher[/boastuff] Servlet.service()
>for servlet jsp threw exception
>org.apache.jasper.JasperException: Unable to compile class for JSP
> 
>An error occurred at line: 87 in the jsp file: /editor.jsp
> 
>Generated servlet error:
>C:\tomcat\work\localhost\boastuff\editor$jsp.java:97: Undefined
>variable or class name: content
>              out.print(content.getAction());
>                        ^
>1 error
> 
> at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
> at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
> at
>org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
> at
>org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
> at
>org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
> at
>org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
> at
>org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
> at boa.iadmin.callEditor(iadmin.java:337)
> at boa.iadmin.submit(iadmin.java:173)
> at boa.iadmin.processRequest(iadmin.java:397)
> at boa.iadmin.doGet(iadmin.java:428)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> at
>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> at
>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
> at
>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
> at
>org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
> at
>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
> at
>org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
> at
>org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
> at java.lang.Thread.run(Thread.java:484)
> 
> 
> 
>********************************************************************************************************************************************
>**** Partial JSP source  - editor.jsp
>*********************************************************************************************************************************************
> 
> 
>
></head>
><body>
> 
><H2>BOA Content Editor</h2>
><center>
> 
><boa:placecontent/>
> 
>
><form name="editor" action="<%=content.getAction()%>">          // line
>87
><TABLE><tr><td>Title:<td>
> 
> 
>*******************************************************************************************************************************************
>****  Source for placecontent tag
>*******************************************************************************************************************************************
> 
>public class EditorContentTag extends
>javax.servlet.jsp.tagext.BodyTagSupport{
> 
>    /** Creates new BOASimpleTag */
>    public EditorContentTag() {
>    }
> 
>    /**  Use this to initialize the tag.
>     */
>     public void doInitBody()throws JspException
>     {
>     }
>    
>     /** Servlet Engine calls this first
>      */
>     public int doStartTag() throws javax.servlet.jsp.JspException {
>     HttpSession session=pageContext.getSession();
>     EditorContent ec=(EditorContent)session.getAttribute("edit");
>     if(ec!=null)
>     {
>      pageContext.setAttribute("content",ec);   
>     }
>     return this.SKIP_BODY;
>     }
>     
>     /** This is done after the body has been evaled.  To loop, use
>this 
>       *  method.
>      */
>     public int doAfterBody() throws javax.servlet.jsp.JspException
>{return this.SKIP_BODY;}
>    
>}
> 
>**********************************************************************************************************************
>*** Source for placecontent TEI clas
>**********************************************************************************************************************
> 
>public class EditorContentTagTEI extends TagExtraInfo{
> 
>
>    public VariableInfo[] getVariableInfo(TagData tagData) 
>    {
>     return new VariableInfo[]{
>         new VariableInfo(
>            "EditorContent",
>            "boa.EditorContent",
>            true,
>            VariableInfo.AT_END)
>     };
>    } 
>}
> 
>
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org