• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 698
  • Last Modified:

about jstl in tomcat!

this is my some cod in my project:
<jsp:useBean id="idCommunity" class="com.beltino.communitymedical.community.Community" scope="page" />

<c:set var="id" value="${param.id}"/>
<c:set var="action" value="${param.action}"/>
<c:set var="retList"/>
<c:if test="${empty id}">
   <c:set var="action" value="new"/>
</c:if>
<c:if test="${!empty id}">
   <c:set var="action" value="edit"/>
   <c:set var="idCommunity" value="${idCommunity.getCommunityInformation(id)}"/>  //&#26377;&#38382;&#39064;
   <c:set var="retList" value="${idCommunity.getCommunityChildByPId(id)}"/>
</c:if>
........
now <c:set var="idCommunity" value="${idCommunity.getCommunityInformation(id)}"/> is error,and the error message is:
org.apache.jasper.JasperException: /webapp/community/editCommunity.jsp(24,3) The function getCommunityInformation must be used with a prefix when a default namespace is not specified

but when i use this page in resin3.0.8 ,it can work well ,but when in tomcat5.0.28,it can not work!

thanks!
0
hgbdelphi
Asked:
hgbdelphi
  • 4
  • 3
1 Solution
 
hgbdelphiAuthor Commented:
jstl can not call javabean 's method with auguments in tomcat like this
 ${idCommunity.getCommunityInformation(id)}"/>????

but it can in resin,how can i do it????


thanks!
0
 
MogalManicCommented:
I don't think you can call methods with parameters in JSTL.  Tomcat is confusing the method call with the JSP 2.0 feature of functions.  You need to call using the following syntax:
${prefix:methodName(param1, param2, ...)}
and also include the TLD

<function>
    <name>methodName</name>
    <function-class>className</function-class>
    <function-signature>
        returnType methodName(param1Type, param2Type, ...)
    </function-signature>
</function>


See this tutorial:
http://www.javaworld.com/javaworld/jw-05-2003/jw-0523-calltag-p2.html
0
 
hgbdelphiAuthor Commented:
thanks to MogalManic!

  but i can do it in resin,so i help this can work in tomcat,can help me again,if i do this like you say,i will change my code much more,can help me  again.

Best Regard!
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
MogalManicCommented:
Tomcat is closer to the standard so my guess is that you are using a feature that is specific to resin.  If you use the JSTL functions they should work in Resin.
0
 
hgbdelphiAuthor Commented:
hi  MogalManic ,
thanks for your help,
 
<c:set var="idCommunity" value="${idCommunity.getCommunityInformation(id)}"/>
to  
<c:set var="idCommunity" value="<%=idCommunity.getCommunityInformation(id)%>"/>

it can work ,but i will change all my code.

Best Regard!
0
 
MogalManicCommented:
Just define the following TLD and you should be able to use it in BOTH resin and Tomcat
Call it Community.tld:

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
    version="2.0">

    <tlib-version>1.0</tlib-version>
    <short-name>c,</short-name>
    <uri>http://MyApp.com/TagLibs/Community.tld</uri>
     <function>
         <name>getCommunityInformation</name>
        <function-class>classPath.CommunityClass</function-class>
        <function-signature>
            int getCommunityInformation(int)
        </function-signature>
    </function>
</taglib>
On your JSP include:
<%@ taglib prefix="cm:" uri="http://MyApp.com/TagLibs/Community.tld"%>
...
<c:set var="idCommunity" value="${cm:idCommunity.getCommunityInformation(id)}"/>


0
 
hgbdelphiAuthor Commented:
thanks!
  i will change some code like you,and another i will do this
<c:set var="idCommunity" value="<%=idCommunity.getCommunityInformation(id)%>"/>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now