File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes problem in custom taglib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in custom taglib" Watch "problem in custom taglib" New topic
Author

problem in custom taglib

Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
THE TAG HANDLER CLASS




THE TLD FILE


THE JSP FILE


THE ERROR MESSAGE
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
foo.AdvisorTagHandler.doTag(AdvisorTagHandler.java:22)
org.apache.jsp.callTagWithBody_jsp._jspx_meth_jose_twb_0(callTagWithBody_jsp.java:91)
org.apache.jsp.callTagWithBody_jsp._jspService(callTagWithBody_jsp.java:53)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28


The error is pointed to this line


I guess the movieList object is not being recieved from the JSP page to the handler class. I do not know how to make it recieve.

could you help?

ARUL JOSE

[ July 22, 2005: Message edited by: Arul Jose ]
[ July 22, 2005: Message edited by: Bear Bibeault ]
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Hello,
By looking at a code it sounds that it should work, perhaps one more way of making a list available to tagHandler would be put this list in a session like
In JSP:
session.setAttribute("movieList",movieList);

In Handler
movieList=(ArrayList)pageContext.getSession().getAttribute("movieList");


regards
Shrinivas
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

perhaps one more way of making a list available to tagHandler would be put this list in a session


Ga! What a messy work-around. Better to find the real problem than resort to something like that.

Arul, your JSP is full of syntax errors. I'm not sure if they're really there or if you were sloppy in writing your post. But look carefully at this line:

<jose:twb movieList="{movieList}" />


Also, in your TLD, I believe that you need to enable rt-expressions for the attribute.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
Hi,

I changed the tld file. i added the <rtexprvalue> true </rtexprvalue> line.

its still not working out.

you have said

Arul, your JSP is full of syntax errors. I'm not sure if they're really there or if you were sloppy in writing your post.


i have just copied and pasted the code.

i could not find any other error. please help.

ARUL JOSE
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
I would also register reservations about passing null in this method:
getJspBody().invoke(null);

That couldn't be the source of the null pointer exception could it?
Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
passing null here is to give output to the browser. you can read about it.
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
Hello Arul,
problem in your code is that you are not checking for movieList to be null in your tag code(doTag() method)...
as in your first invocation of your tag, you are passing only user, the tag will find movieList to be null and it will throw you NullPointerException when you do "movieList.iterator()"...
your could should be



hope this helps
Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
think you did a great reading. Thank you so much.

i also noticed this problem later. now i have corrected it.

now my jsp file is



This is the error message :

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: jsp.error.beans.property.conversion
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
org.apache.jsp.callTagWithBody_jsp._jspx_meth_jose_twb_0(callTagWithBody_jsp.java:83)
org.apache.jsp.callTagWithBody_jsp._jspService(callTagWithBody_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

I think the specification now mandates both getter and setter methods for all tag attributes defined in the tld (which you dont have in your tag class)

cheers,
ram.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

No. Getters are not required.
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
arul,

you are not using the correct syntax for EL in your JSP

<jose:twb user="aruljose" movieList="{request.movieList}" />

here it should be ${request.movieList} instead of {request.movieList}

hope it works now
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

As I said earlier, check your JSP for simple syntax errors such as this. You should not be needing to rely upon others to find out where you forgot a $.
Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
Thanks. i corrected it.



still gettin error

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: jsp.error.beans.property.conversion
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
org.apache.jsp.callTagWithBody_jsp._jspx_meth_jose_twb_0(callTagWithBody_jsp.java:83)
org.apache.jsp.callTagWithBody_jsp._jspService(callTagWithBody_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28
len atwood
Greenhorn

Joined: Aug 16, 2005
Posts: 1
hi,
i have the same problem. my jsp code segment is:

<%@ taglib uri="table_jsp.tld" prefix="tbl" %>
<jsp:useBean id="tableSrc" class="mytable.SimpleTable"
type="mytable.TableDataSource" scope="session" />

<tbl:table rows="10" border="1"
datasource="${tableSrc.source}" />


any help would be greatly appreciated
len

org.apache.jasper.JasperException: jsp.error.beans.property.conversion
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
org.apache.jsp.tbl_jsp._jspx_meth_tbl_table_0(org.apache.jsp.tbl_jsp:115)
org.apache.jsp.tbl_jsp._jspService(org.apache.jsp.tbl_jsp:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
oracle.adf.view.rich.faces.application.DelegatingViewHandler.renderView(DelegatingViewHandler.java:35)
oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:146)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:310)
oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:183)
oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
can you give your jars list?
Marco Fung
Greenhorn

Joined: Jul 25, 2005
Posts: 7
In your Tld file, have you try to define the movieList rtexprvale to true?

<attribute>
<name>movieList</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in custom taglib
 
Similar Threads
Problem in Adding Attributes to TLD file
custom "advice" tag example
Doubt in HFSJ..pg 511 creating simple tag with attribute
org.apache.jasper.JasperException: Unable to compile class for JSP:
Simple Tag Handler - doubt - when is doTag() called ?