You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Angelo Giugliano <a....@eustema.it> on 2004/09/27 14:05:41 UTC

Problem with Tomcat 5.0.28

Hello to all and thousand thanks in advance  

My architecture is composed by: jsp-tag handler-delegate-session-entity-db
I was thinking to come near to jsp2.0 (el-jstl1.2). I'm doing some test.

My test is composed by: jsp-tag file-utility class (TestDelegate)
Page jsp is composed by:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tf" tagdir="/WEB-INF/tags" %>
<%@ page import="java.util.*" %>
<%@ page import="test.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.jsp.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page isELIgnored="false" %>

<html><head><title>Test per JSP 2.0</title></head>
<body bgcolor="#ABFFD9">

<%
Collection a = new java.util.ArrayList();
a.add("**** pippo ****");
a.add("**** pluto ****");
%>

<!--       IN    -->
<tf:test collIn="${a}"/>

<!--      OUT  -->
<c:forEach var="item" begin="0" items="${collOut}"> 
    <jsp:useBean id="item" type="java.lang.String"/>
    ${item}
</c:forEach> 

</body>
</html>


Jsp don't work because throws exception: 

javax.servlet.ServletException: javax.servlet.jsp.JspException: null
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.test_jsp._jspService(test_jsp.java:160)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
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:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)


root cause 

java.lang.NullPointerException
	test.TestDelegate.modifyCollection(TestDelegate.java:35) Using scriplet in tag (<tf:test collIn="<%=a%>"/>) work but using EL (${a}) don't work. Could be tomcat's bug (5.0.28)?

Thank You.

Angelo Giugliano   e-mail: a.giugliano@eustema.it

Re: Problem with Tomcat 5.0.28

Posted by Angelo Giugliano <a....@eustema.it>.
Hi and Thank you for your response

My test is composed by: jsp-tag file-utility class (TestDelegate)

JSP is composed by:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tf" tagdir="/WEB-INF/tags" %>
<%@ page import="java.util.*" %>
<%@ page import="test.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.jsp.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page isELIgnored="false" %>

<html><head><title>Test per JSP 2.0</title></head>
<body bgcolor="#ABFFD9">

<%
Collection a = new java.util.ArrayList();
a.add("**** pippo ****");
a.add("**** pluto ****");
%>

<!--       IN    -->
<tf:test collIn="${a}"/>

<!--      OUT  -->
<c:forEach var="item" begin="0" items="${collOut}">
    <jsp:useBean id="item" type="java.lang.String"/>
    ${item}
</c:forEach>

</body>
</html>






Tag file is composed by:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="collIn" required="true" type="java.util.Collection"
description="Parametro in ingresso" %>
<%@ variable name-given="collOut" description="Parametro in uscita"
variable-class="java.util.Collection" scope="AT_END" %>
<%@ tag import="test.*" %>
<%@ tag import="java.util.*" %>
<%@ tag import="javax.servlet.jsp.*" %>
<%@ tag import="javax.servlet.*" %>
<%@ tag import="test.*" %>


<%
TestDelegate testDelegate = new TestDelegate();
Collection collOut = null;
collOut = testDelegate.modifyCollection(collIn);
request.setAttribute("collOut",collOut);
%>





TestDelegate class is composed by:

public class TestDelegate {
 ......................................

  public Collection modifyCollection(Collection in) {
    Collection out = in;
    out.add("**** paperino ****");
    return out;
  }
.......................................


Using scriplet in tag (<tf:test collIn="<%=a%>"/>) work but using EL (${a})
don't work. Could be tomcat's bug (5.0.28) or something other as an example
scope?

Thank you















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


Re: Problem with Tomcat 5.0.28

Posted by QM <qm...@brandxdev.net>.
On Mon, Sep 27, 2004 at 02:05:41PM +0200, Angelo Giugliano wrote:
: <%
: Collection a = new java.util.ArrayList();
: a.add("**** pippo ****");
: a.add("**** pluto ****");
: %>
: 
: <!--       IN    -->
: <tf:test collIn="${a}"/>
:  [snip]
: java.lang.NullPointerException
: 	test.TestDelegate.modifyCollection(TestDelegate.java:35) Using scriplet in
: tag (<tf:test collIn="<%=a%>"/>) work but using EL (${a}) don't work. Could be
: tomcat's bug (5.0.28)?

Your post is missing some key info:
1/ what does modifyCollection() do?
2/ how is modifyCollection() called from the JSP?
3/ you mention v5.0.28; did it work in an earlier version of 5.x, or
4.1.x?

It's been a long time since I've done raw JSP with scriptlets and the
like; but I don't see where you're placing the collection "a" in a
scope that can be manipulated by the tags.

(Do the JSTL taglibs work on locally-delared variables, or just those in
a scope?  I don't recall.)

Along those same lines, I thought variables declared in <% %> were in a
local scope (aka a code block) but those declared in <%! %> were global.
That may also be the problem.

-but, as I said before, it's been a while since I've played with raw JSP
instead of pure JSTL. ;)

-QM

-- 

software  -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com


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