Custom tag in JSPTableContainerProvider/tabletopbottom.jsp
Tried creating a new tag based upon 'getHasFrame' tag in 'desktopTable.tld'. The jsp referenced above throws the following exception:
ERROR: JspRequestDispatcher:
javax.servlet.ServletException: Problem processing JSP: /../JSPTableContainerProvider/tabletopbottom.jsp
at com.sun.portal.providers.jsp.JspRequestDispatcher.getJspResource(JspRequestDispatcher.java:164)
at com.sun.portal.providers.jsp.JspRequestDispatcher.include(JspRequestDispatcher.java:97)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:408)
at jsps.etc._opt._SUNWps._desktop._pinpoint_en_US._Home._html._table_jsp._jspService(_table_jsp.java:526)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sun.portal.providers.jsp.JspServletWrapper.service(JspServletWrapper.java:182)
at com.sun.portal.providers.jsp.JSPProvider.processJspFile(JSPProvider.java:692)
at com.sun.portal.providers.jsp.JSPProvider.processJspFile(JSPProvider.java:672)
at com.sun.portal.providers.jsp.JSPProvider.getContent(JSPProvider.java:471)
at com.sun.portal.desktop.context.PSContainerProviderContext.getContent(PSContainerProviderContext.java:367)
at com.sun.portal.desktop.taglib.containerProviderContext.GetContentTag.doStartTag(GetContentTag.java:33)
at jsps.etc._opt._SUNWps._desktop._pinpoint_en_US._PinPointTabContainer._html._tab_jsp._jspService(_tab_jsp.java:596)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sun.portal.providers.jsp.JspServletWrapper.service(JspServletWrapper.java:182)
at com.sun.portal.providers.jsp.JSPProvider.processJspFile(JSPProvider.java:692)
at com.sun.portal.providers.jsp.JSPProvider.processJspFile(JSPProvider.java:672)
at com.sun.portal.providers.jsp.JSPProvider.getContent(JSPProvider.java:471)
at com.sun.portal.providers.containers.jsp.tab.JSPTabContainerProvider.getContent(JSPTabContainerProvider.java:535)
at com.sun.portal.desktop.context.PSContainerProviderContext.getContent(PSContainerProviderContext.java:367)
at com.sun.portal.desktop.context.PSDesktopContext.getContent(PSDesktopContext.java:957)
at com.sun.portal.desktop.DesktopServlet.doGetPost(DesktopServlet.java:493)
at com.sun.portal.desktop.DesktopServlet.service(DesktopServlet.java:303)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:897)
at com.iplanet.server.http.servlet.WebApplication.service(WebApplication.java:1059)
at com.iplanet.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunner.java:959)
The tagclass referenced by the tag was compiled on the server.
No logging associated with the doStartTag() method or the tag's constructor ever comes through.
Seems like it can't find the class at all ?
The jsp complains about this line:
<dttable:getHasHeader id="hasHeader" scope="request"/>
where --
<%@ taglib uri="/tld/desktopTable.tld" prefix="dttable" %>
and the tld file contains the following tag:
<tag>
<name>getHasHeader</name>
<tagclass>com.xyz.portal.desktop.tags.GetHasHeaderTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
Any clues ?
Has anyone been able to get their own tags to work? Here's the very odd situation to clarify a little of what my colleague originally posted:
Custom tag class written based on the 'getHasFrame' tag
Added a declaration to the desktopTable.tld file for the tag
Put the classes in
....../desktop/classes
...../SUNWam/lib
as both jar files and plain-old class files
Made sure the jars and directories are in the classpath property in jvm12.conf and in the jspCompilerWARClassPath property of desktopconfig.properties (trying anything at this point)
Even if the tag is screwed up, here's the kicker....I just did a Class.forName() on the tag class and that throws a Throwable. eh? We've written a bunch of other custom classes that we just use in our JSPs with no problem. I don't get why this is such a special case.
Anybody got a clue for me?
In which directories did you place the tld and
*.class files for the taglib?
The class files should probably be in
/etc/opt/SUNWps/desktop/classes (or someplace else in
the web server's classpath)
The tld should probably be in
/etc/opt/SUNWps/desktop/default/tld (default may be
named differently if you changed the "desktop type"
in the admin console under the desktop definition).
Similar Messages
-
How to use custome tag lib in the JSP page?
How to use custome tag lib in the JSP page?...with JDeveloper
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.2/state/content/navId.4/navSetId._/vtTopicFile.working_with_jsp_pages%7Cjsp_ptagsregistering~html/
-
Dynamic include in a custom tag, called from a jsp
Hello, I would like to be able to dynamically include other jsp's from within a custom tag that I create. is this possible?
in a jsp page i would just write <%@ include file="file.jsp" %> and all would be ok... but if i do an out.println( "<%@ include file=\"file.jsp\" %>" ); inside a custom tag bean then it doesn't work. it just prints out the command to the page as plain text.
I do understand why this is happening, but can anyone offer me a way around this problem?
Thanks in advance,
RandyThat's actually the same result as you get with a normal include - The method I suggested is a dynamic include similar to the <jsp:include> tag, not the <%@ include %> tag.
When you use a dynamic include, the included page is compiled and 'invoked' as serarately, and the result is what gets included, not the actual source. To get the behaviour you want would require an include directive (the <%@ include %> tag) which I don't think has an equivalence you can use inside a custom tag.
What you can do is pass attributes from the tag class like this:
pageContext.setAttribute(<name>, <object>, pageContext.REQUEST_SCOPE);
and then remove them after the include using pageContext.removeAttribute.
I'm not certain, but this implies that if you declare your variables with a <jsp:usebean> tag with request scope, instead of normal Java variable declarations, you should be able to use them in the page included by the custom tag.
*** in the jsp ***
<jsp:useBean id="myVar" scope="request" class="java.lang.String" />
<% myVar = "Something"; %>
// Now call the tag which uses the pageContext.include() mehtod.
*** end ***
*** in the include ***
<jsp:useBean id="myVar" scope="request" class="java.lang.String" />
<%= myVar + " something else" %>
*** end ***
Let me know if it works. -
In custom tag, trying to include JSP Page, not processing tags
Now I have this in the correct forum!
I am in a custom tag where one of my attributes (myIncludePage) is the name of another JSP file that I want to include. So, in my custom tag doStartTag() I have:
out.println("<td>");
pageContext.include(myIncludePage);
out.println("</td>");
The included page is rendered with the custom tags in it not processed (I see my tags in the generated HTML)
How do I get the included page to be "processed"?
Thanks in advance,
SamSorry, wrong forum, should be in the JSP forum. Hope someone can still help!
-
In custom tag, trying to include JSP page, not processing JSP tags
I am in a custom tag where one of my attributes (myIncludePage) is the name of another JSP file that I want to include. So in my custom tag doStartTag() I have:
out.println("<td>");
pageContext.include(myIncludePage);
out.println("</td>");
The included page is rendered with the custom tags in it not processed (I see my tags in the generated HTML)
How do I get the included page to be "processed"
Thanks in advance
SamSorry, wrong forum, should be in the JSP forum. Hope someone can still help!
-
Calling jsp custom tag from jsp expression
hi there,
I have a problem calling oracle(or any other) custom tag from inside a jsp expression.(i.e.)embeding <jbo:tagname...> into <%......%>.
For example:
I need to get the value of a jsp parameter, but the parameter name is dynamic (retrieved from a DataBase)
So I though it would be something link that:
<%=request.getParameter(<jbo:ShowValue datasource="ds" dataitem="ParamName" ></jbo:ShowValue>) %>
where <jbo:ShowValue is an Oracle custom tab that retrieves the value of a certain dataItem(certain field).
But it does not work.........
if any body can tell me how to overcome, or work around it, I'll be so pleased.
Regards,
Remoun AnwarHi,
You get the custom tag output into a hidden variable (say 'key') and use the request.getParameter("key")
Hope u got the answer...
Regards
ravi -
I'm using custom tags in my app (JSP 1.2). My tld is located in WEB-INF/tlds (not packaged in a JAR), meaning that the uri in the tld file should be picked up by JSP 1.2's autodiscovery. This works fine in actual deployment, but Nitrox claims that:
"The tag library uri "mytaglib" cannot be mapped to an existing tld file. "
when I attempt to reference it as follows from within my jsps:
<%@ taglib uri="mytaglib" prefix="m" %>
Do you know if this is a bug, or have any suggestions as to why the tld uri isn't being picked up by Nitrox?
Thanks,
JohnThis is a known (kind of) issue. There are 2 easy workarounds:
1- Specify the path to the tld file in the uri attribute. For example:
<%@ taglib uri="/WEB-INF/mytaglib.tld" prefix="m" %>
2- Map the tld file in web.xml. For example:
<taglib>
<taglib-uri>mytaglib</taglib-uri>
<taglib-location>/WEB-INF/mytaglib.tld</taglib-location>
</taglib>
M7 Support -
Custom Tag Error with Weblogic SP9
Hi
I seem to be having a problem with a custom tag that I wrote. When I run the JSP
on WLS (without a service pack), the generated java code uses the weblogic.utils.StringUtils
class to interprete jsp expressions that are passed into the custom tag's attribute
(on the JSP). The method called on this StringUtils class is valueOf(). This method
in essence makes sure that the result of the expression is not null and then subsequently
calls a toString() on the value. Note that if the value is null it simply returns
an empty string.
The problem is that when we go to service pack 9, this method is not called (StringUtils.valueOf()).
Now the problem arises if first of all the result of the expression statement
in the custom tag definintion (on the JSP) is null. Secondly, it will also error
out when the setter method is called within the custom tag, if the object returned
from the expression does not match the one that is expected by the tag... in our
case a String.
Here's a sample usage of the tag:
<wescombop:selectTag
selectName="buildingNumber"
selectedItem="<%= buildingJB.getBuildingNumber()%>"
trimSelectedItem="true"
selectTagDataName="buildingNumberDataAttribute" />
Note: buildingJB.getBuildingNumber() returns BigDecimal
Here's a snipett of the line generated java:
* Without the service pack
comwestfieldgrp_wescom_bop_view_tag_SelectTag_1.setSelectedItem(weblogic.utils.StringUtils.valueOf(buildingJB.getBuildingNumber()));
*With Service Pack 9
comwestfieldgrp_wescom_bop_view_tag_SelectTag_1.setSelectedItem(buildingJB.getBuildingNumber());
Note: The setSelectedItem() method expects a String object as a parameter, so
the code with service pack 9 will result in a compilation error, since buildingJB.getBuildingNumber()
returns a BigDecimal.
Let me know if you need more explanation.
Has anyone experience this problem before... Any help would be deeply appreciated.
Thanks all.
Niran
Modify the <cewolf:param> tag.
<cewolf:chart id="confchart" title="Reports" type="bar3d" yaxislabel="Time"> <cewolf:data>
<cewolf:producer id="report"> <cewolf:param name="type" value="all" > </cewolf:param>
</cewolf:producer> </cewolf:data> </cewolf:chart>
"Balakrishnan" <[email protected]> wrote:
>
>We are using cewolf charting library in weblogic 7.0. The charting library
>is implemented
>as custom jsp tag library module.
>
>However, when the use the tag for displaying the chart, weblogic is producing
>this compiler error.
>
>/reports/reportsView.jsp(108): no corresponding open tag for tag extension
>close:
>//[ null; Line: 108]
>
>Here's the corresponding source of the jsp file:
>
> <cewolf:chart id="confchart" title="Reports" type="bar3d" yaxislabel="Time">
> <cewolf:data>
> <cewolf:producer id="report">
> <cewolf:param name="type" value="all" /> (<-- Error occurs
>here.
>Line no: 108)
> </cewolf:producer>
> </cewolf:data>
> </cewolf:chart>
>
>I've also checked the corresponding tld file and it is in place.
>
>The same code without any modifications is working fine in tomcat. Can
>you please
>let me know what needs to be corrected to make this work?
-
Using EL in custom tag with JSP1.2 container
I search the the Forum here and Google for a method how I can use expression language in my custom tag. But I have to use a JSP1.2 container which makes it quite difficult. What I need is startsWith-Tag which looks like this.
<str:startsWith condition1="${sql.rows[0].MY_COLUMN}" condition2="MyCondition">
</str:startsWith>Right now my tag works, but instead of the database of MY_COLUMN the string ${sql.rows[0].MY_COLUMN} is submitted.
In the TLD I specified rtexprvalue with true. My custom tag extends javax.servlet.jsp.jstl.core.ConditionalTagSupport.
What I read here was that I have to evaluate the el expression myself, but how do I do this? I hope someone can give me a hint how to make the tag working correctly.
TIA
AxelYou might find the source code of MicroNova YUZU (http://sourceforge.net/projects/micronova-yuzu) useful. It is an EL-based tag library that supports both JSP 1.2 and 2.0. See "jsp12" and "jsp20" subdirectories for version-specific EL handling. Hope this helps.
-
Include external html trough code in a custom tag
Hi,
I have a custom tag. The component class (say MyComponentUI) for my custom component extends UIComponentBase.
I want to include an external html page, which url is formed using the content of an attribute of my tag (for example, the "value" attribute), through the MyComponentUI code.
Can anyone give me some help ?
PietroThat's actually the same result as you get with a normal include - The method I suggested is a dynamic include similar to the <jsp:include> tag, not the <%@ include %> tag.
When you use a dynamic include, the included page is compiled and 'invoked' as serarately, and the result is what gets included, not the actual source. To get the behaviour you want would require an include directive (the <%@ include %> tag) which I don't think has an equivalence you can use inside a custom tag.
What you can do is pass attributes from the tag class like this:
pageContext.setAttribute(<name>, <object>, pageContext.REQUEST_SCOPE);
and then remove them after the include using pageContext.removeAttribute.
I'm not certain, but this implies that if you declare your variables with a <jsp:usebean> tag with request scope, instead of normal Java variable declarations, you should be able to use them in the page included by the custom tag.
*** in the jsp ***
<jsp:useBean id="myVar" scope="request" class="java.lang.String" />
<% myVar = "Something"; %>
// Now call the tag which uses the pageContext.include() mehtod.
*** end ***
*** in the include ***
<jsp:useBean id="myVar" scope="request" class="java.lang.String" />
<%= myVar + " something else" %>
*** end ***
Let me know if it works. -
Tomcat4: Illegal to flush within a custom tag
I tried to deploy to Tomcat4.1.18 a jsp-struts application developed with JDeveloper 9.0.3.1, simply obtained using the "Complete Struts-Based JSP Application" Wizard.
When I access to a page containing the
"jbo:DataRecord" tag or the "jbo:DataTable" I get this exception in the error log file (I do not know if other tags give this same error, but for example "jbo:DataScroller" does not):
2003-04-15 09:28:35 ApplicationModule release mode is: Stateful
2003-04-15 09:28:36 jsp: init
2003-04-15 09:28:37 jsp: init
2003-04-15 09:28:37 IO Error
java.io.IOException: Illegal to flush within a custom tag
at javax.servlet.jsp.tagext.BodyContent.flush(BodyContent.java:115)
at oracle.jbo.html.jsp.datatags.ComponentTag.doStartTag(ComponentTag.java:69)
at org.apache.jsp.PazientiDateEventiViewLink1_0005fDateEventiEventiViewLink1$jsp._jspService(PazientiDateEventiViewLink1_0005fDateEventiEventiViewLink1$jsp.java:157)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
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:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1014)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:417)
at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:390)
at oracle.jbo.html.struts11.BC4JRequestProcessor.processActionForward(BC4JRequestProcessor.java:98)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:271)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
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:190)
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:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
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:468)
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:174)
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.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:429)
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495)
at java.lang.Thread.run(Thread.java:484)
2003-04-15 09:28:46 jsp: init
2003-04-15 09:28:46 ApplicationModule release mode is: Stateful
Deploying on a standalone OC4J everything works.
Is there some configuration to add to the web.xml file or somewhere else? I tried also on Tomcat 4.0.3 with same results.
I added this lines in web.xml to avoid the problems descripted in thread BC4J entity objects vs EJB2.0 entity beans
<init-param>
<param-name>enablePooling</param-name>
<param-value>false</param-value>
</init-param>
Other non-struts-based webapps developed with JDev 9.0.2 and 9.0.3 were deployed correctly on Tomcat 4.1.18.
Thanks,
Marco.Hi Steve,
I looked better at my page and it has been modified from that produced by the wizard. In fact, the problem arises substituting a DataTable tag with a RowsetIterate in which I put a DataRecord.
Here there is a simple page which produces this error (I see the error only in the error log of Tomcat localhost_log.txt, not on the page):
<%@ page language="java" import="oracle.jbo.*" errorPage="errorpage.jsp" contentType="text/html;charset=windows-1252" %>
<%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html>
<head>
<META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
<LINK REL=STYLESHEET TYPE="text/css" HREF="bc4j.css">
<TITLE><bean:message key="browse.title"/></TITLE>
</head>
<body>
<jbo:DataTransaction appid="Test3Module" />
<h3><bean:message key="browse.header" arg0="CategoryView1"/></h3>
<table border="0">
<tr>
<td ALIGN="right"><jbo:DataScroller datasource="Test3Module.CategoryView1"/></td>
</tr>
<tr>
<%-- REPLACED DataTable WITH a RowsetIterate in which I put a DataRecord --%>
<jbo:RowsetIterate datasource="Test3Module.CategoryView1" userange="true" >
<td>
<jbo:DataRecord datasource="Test3Module.CategoryView1" />
</td>
</jbo:RowsetIterate>
<%--
<td><jbo:DataTable datasource="Test3Module.CategoryView1" edittarget="/edit_CategoryView1.do"/></td>
--%>
</tr>
</table>
</body>
</html>
In this case, it is not so hard to avoid to put in the pages such a code.
Thanks,
Marco. -
Custom Tag Implementation seems inefficient
I've been playing around a bit (alright, so maybe not all that much)
with custom tags, and it seems like the actual implementation of custom
tags (tag handler object(s) per tag) is much more resource-intensive
than would be justified. With Weblogic 5.1 SP6, has anyone had the
opportunity to compare performance of a typical JSP page w/ and w/out
custom tags?
My first impression of custom tags was that you could define tags
and behaviors that the JSP compiler would then compile into your JSP
class; there would be no performance hit during page execution. The Java
code used to write these tags would either be included inline in the JSP
page code, or else act essentially as static (threadsafe) classes into
which threads executing JSP pages would call into. This approach means
less resources consumed and less setup/teardown time in exchange for
fatter JSPC'd code.
Instead (and correct me if I am wrong), it appears that each
distinct custom tag has a pool of instantiated handler objects lying
around in memory, and each time a custom tag is used, there is a
little performance hit in the setup & teardown of each handler object's
pageContext, etc...
Now admittedly, as another poster (I believe Mr. Purdy) pointed out,
a "little" ain't all that much... unless there are thousands of those
"little" hits.
Moreover, I don't see much benefit in having instantiated objects do
the heavy lifting. I'd rather have my auto-compiled JSP classes be a
little more bloated than suffer any performance hit. (I do, however,
like the fact that custom tags allows for cleaner JSP code, not to
mention makes for a cleaner break between the creative and coding work.)
For those of you who've had more extensive experience with custom
tags, am I missing the target? Is the performance hit negligible for
heavily-used or complex pages? And/or is the performance hit outweighed
by code and development cleanliness?
Thanks for any input.
Jack
Hi Sri
Looks like you've found an inefficiency in WebLogic's JSP compiler - it
should be reusing tag instances within the same page. BEA should fix this
hopefully.
> So even if a page has 4 tags and 100 users, we have 400 objects just
> because we use tags.
Sure, assuming you have 100 concurrent users (and 100 threads in the servlet
engine). Though creating 400 objects is not a big deal in Java; most non
trivial Java applications / services create millions of objects.
Its also worth noting that having a seperate object instance per tag per
calling thread means that you don't have to do any synchronisation in the
custom tag (since you're guarenteed to be called by one thread only) so you
get maximum thread throughput at the expense of some object allocation.
If you really don't like the idea of creating a few java objects per request
you could use XSLT to post process JSP files to replace tag occurencies with
Java scriptlets - though I'm not sure the extra complexity and restrictions
that this mechanism imposes is worth it at all. Custom tags rock! ;-)
J.
James Strachan
=============
email: [email protected]
web: http://www.metastuff.com
"Sri" <[email protected]> wrote in message
news:[email protected]...
> This post had some interesting aspects about custom tags that contradict
> what I see in the generated java code by the JSP container. I am using
> weblogic 5.1 sp6 and I have a jsp file that uses a custom tag "xyz:for" a
> couple of times. the tags are not nested.
> The java code indicates that two separate instances for the "xyz:for" tag
> were created.
>
> try
>
> calicothunder_presentation_tags_ForTag_0 = new
> calico.thunder.presentation.tags.ForTag();
>
> ..............
>
> } finally
>
> if (_calico_thunder_presentation_tags_ForTag_0 != null)
> calicothunder_presentation_tags_ForTag_0.release();
> }
>
> Further down
>
> try {
> calicothunder_presentation_tags_ForTag_1 = new
> calico.thunder.presentation.tags.ForTag();
> ...............
>
> } finally
>
> if (_calico_thunder_presentation_tags_ForTag_1 != null)
> calicothunder_presentation_tags_ForTag_1.release();
> }
>
> The code is creating two different objects for every request. It is not
> reusing the same object.
> The release is just cleaning up the current instance, which may be garbage
> collected at some later stage.
> So even if a page has 4 tags and 100 users, we have 400 objects just
> because we use tags.
>
> Just trying to understand this better..
> thanks - Sri
>
>
>
> "James Strachan" <[email protected]> wrote in message
> news:[email protected]...
> > Hi Jack
> >
> > I think you're right to be concerned and it is a valid concern.
> >
> > In the scheme of things in my experience the cost of using custom tags
is
> > quite minimal. Tag instances are reused on the same page so if I have
> > several non-nested <foo:bar> tags on a page the single FooBarTag
instance
> > will be reused for each tag occurance.
> >
> > Consider other Java code, say, string concatenation. Consider the
> following
> > expression.
> >
> > String c = a + b;
> >
> > Fairly minimal code you might think. However this line actually involves
> the
> > creation of a StringBuffer instance, the call of 2 methods and the
> creation
> > of a second String object instance (never mind the internal char[]
object
> > instance that is created inside the new Strings constructor).
> >
> > A typical use of a custom tag involves one object construction, N
> > setProperty() method calls (one for each attribute of the tag) and the
> > startTag / endTag method calls.
> >
> > So on balance I'd say the custom tags mechanism is quite small and
> > efficient.
> >
> > Though note that if you use large numbers (say hundreds) of different
> kinds
> > of tags then you'll have a much greater object allocation overhead.
> >
> > --
> > J.
> >
> > James Strachan
> > =============
> > email: [email protected]
> > web: http://www.metastuff.com
> > "Jack Lin" <[email protected]> wrote in message
> > news:[email protected]...
> > > I've been playing around a bit (alright, so maybe not all that much)
> > > with custom tags, and it seems like the actual implementation of
custom
> > > tags (tag handler object(s) per tag) is much more resource-intensive
> > > than would be justified. With Weblogic 5.1 SP6, has anyone had the
> > > opportunity to compare performance of a typical JSP page w/ and w/out
> > > custom tags?
> > >
> > > My first impression of custom tags was that you could define tags
> > > and behaviors that the JSP compiler would then compile into your JSP
> > > class; there would be no performance hit during page execution. The
Java
> > > code used to write these tags would either be included inline in the
JSP
> > > page code, or else act essentially as static (threadsafe) classes into
> > > which threads executing JSP pages would call into. This approach means
> > > less resources consumed and less setup/teardown time in exchange for
> > > fatter JSPC'd code.
> > > Instead (and correct me if I am wrong), it appears that each
> > > distinct custom tag has a pool of instantiated handler objects lying
> > > around in memory, and each time a custom tag is used, there is a
> > > little performance hit in the setup & teardown of each handler
object's
> > > pageContext, etc...
> > > Now admittedly, as another poster (I believe Mr. Purdy) pointed
out,
> > > a "little" ain't all that much... unless there are thousands of those
> > > "little" hits.
> > > Moreover, I don't see much benefit in having instantiated objects
do
> > > the heavy lifting. I'd rather have my auto-compiled JSP classes be a
> > > little more bloated than suffer any performance hit. (I do, however,
> > > like the fact that custom tags allows for cleaner JSP code, not to
> > > mention makes for a cleaner break between the creative and coding
work.)
> > >
> > > For those of you who've had more extensive experience with custom
> > > tags, am I missing the target? Is the performance hit negligible for
> > > heavily-used or complex pages? And/or is the performance hit
outweighed
> > > by code and development cleanliness?
> > >
> > > Thanks for any input.
> > > Jack
> > >
> > >
> >
> >
>
>
-
Custom tag as performance hits.
Hi All,
I want to know if there is a correlation between the number of custom tags used in
a JSP page and the page's performance.
Is there a guideline/study which indicates (or otherwise) that increasing the number
of custom tags decreases the loading (rendering) time of the JSP page. I understand
that more tags mean more jsp-compilation time but I am interested in runtime performance.
Thanks,
Anu
I want to know if there is a correlation between the number of custom tags used in
> a JSP page and the page's performance.
>
> Is there a guideline/study which indicates (or otherwise) that increasing
the number
> of custom tags decreases the loading (rendering) time of the JSP page. I
understand
> that more tags mean more jsp-compilation time but I am interested in
runtime performance.
Each additional tag adds some runtime overhead. The overhead is primarily
determined by the quality of the tag implementation. I'd rather have 1000
well written tags than 1 poorly written one ;-) ... e.g. if you are doing
JDBC calls from a tag, then you will probably get into trouble in a hurry.
Peace,
Cameron Purdy
Tangosol, Inc.
Clustering Weblogic? You're either using Coherence, or you should be!
Download a Tangosol Coherence eval today at http://www.tangosol.com/
"Anu Agrawal" <[email protected]> wrote in message
news:3cd821c0$[email protected]..
>
-
Further custom tag travails...
All,
I have posted previously that custom tags can not handle JSP in their
attributes. This turns out to be incorrect. In fact, they can, but
there are some serious bugs when using it which made it seem like they
couldn't.
The following jsp works perfectly fine:
<% String myAttribute="Thusly my attribute is" %>
<mytaglib:mytag myattribute="<%=myAttribute%>" />
However, the following jsp will break:
<mytaglib:mytag myattribute="<%="Thusly my attribute is"%>" />
because the jsp parser thinks that the second quote is ending the
attribute instead of starting a string. Hence, the jsp compiler sees:
<mytaglib:mytag myattribute="<%="
and then some garbage including a > which it assumes means that mytag is
closing. This really, really screws things up...
The exact error I get is:
/tagtester.jsp(38): no corresponding open tag for tag extension close:
Now, I also get an error if I do something like this:
<% String myAttribute="Thusly my attribute is" %>
<mytaglib:mytag myattribute=" <%=myAttribute%>" />
Where I have put some one space before the jsp. The error message is
different:
/_tagtester.java:84: String not terminated at end of line.
Looking at the jsp .java file indicates that this also is a parsing
problem...
Is weblogic aware of these issues? Will they be fixed in sp6?
Thanks,
Carson
This is a consequence of the JSP spec and how it parses attribute values.
Similar issues occur using standard boilerplate XML.
The easy way around these problems is to use the fact that both single and
double quotes are allowable in XML attribute values so try using code like
this instead:-
<mytaglib:mytag myattribute='<%="Thusly my attribute is"%>' />
Then you will not get any JSP compilation errors.
Regards
James
James Strachan
=============
email: [email protected]
web: http://www.metastuff.com
"Cameron Purdy" <[email protected]> wrote in message
news:[email protected]...
> I saw this refererred to (in a different context altogether) in some W3
> documents referring to issues with input type attributes and xml ... I
think
> in the context of XSL. In other words, I am not sure if it is a WL bug or
> just something that you can not do. I know that isn't the answer that you
> are looking for ;-( ... perhaps you can escape some of those quotes.
>
> --
>
> Cameron Purdy
> [email protected]
> http://www.tangosol.com
> WebLogic Consulting Available
>
>
> "Carson Gross" <[email protected]> wrote in message
> news:[email protected]...
> > All,
> >
> > I have posted previously that custom tags can not handle JSP in their
> > attributes. This turns out to be incorrect. In fact, they can, but
> > there are some serious bugs when using it which made it seem like they
> > couldn't.
> >
> > The following jsp works perfectly fine:
> >
> > <% String myAttribute="Thusly my attribute is" %>
> > <mytaglib:mytag myattribute="<%=myAttribute%>" />
> >
> > However, the following jsp will break:
> >
> > <mytaglib:mytag myattribute="<%="Thusly my attribute is"%>" />
> >
> > because the jsp parser thinks that the second quote is ending the
> > attribute instead of starting a string. Hence, the jsp compiler sees:
> >
> > <mytaglib:mytag myattribute="<%="
> >
> > and then some garbage including a > which it assumes means that mytag is
> > closing. This really, really screws things up...
> >
> > The exact error I get is:
> >
> > /tagtester.jsp(38): no corresponding open tag for tag extension close:
> >
> > Now, I also get an error if I do something like this:
> >
> > <% String myAttribute="Thusly my attribute is" %>
> > <mytaglib:mytag myattribute=" <%=myAttribute%>" />
> >
> > Where I have put some one space before the jsp. The error message is
> > different:
> > /_tagtester.java:84: String not terminated at end of line.
> >
> > Looking at the jsp .java file indicates that this also is a parsing
> > problem...
> >
> > Is weblogic aware of these issues? Will they be fixed in sp6?
> >
> > Thanks,
> > Carson
> >
>
>
-
"Newbie Unable to load class for custom tag"
I have recently written a custom tag but I have been unable to implement it in a JSP because the server is unable to load the .class file. Below I have supplied the files that contribute to make up the custom tag, aswell as the JSP file used to implement it.
genericDBConnect.java
stored in C:\jakarta-tomcat-3.2.3\webapps\exper\WEB-INF\classes\jsp\tags\dbase
package jsp.tags.dbase;
import java.io.*;
import java.sql.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class genericDBConnect extends BodyTagSupport
private String odbcDriver;
private String dataSource;
public void setOdbcDriver(String driver)
odbcDriver = driver;
public void setDataSource(String source)
dataSource = source;
public int doStartTag() throws JspException
return EVAL_BODY_INCLUDE;
public int doEndTag() throws JspException
try{
pageContext.getOut().print("This is the value of odbcDriver = " + odbcDriver + "and dataSource = " + dataSource);
catch(Exception ioException)
System.err.println("Exception thrown in genericDBConnect.doEndTag():");
System.err.println(ioException);
throw new JspException(ioException);
return EVAL_PAGE;
WEB.XML
Stored in: C:\jakarta-tomcat-3.2.3\webapps\exper\WEB-INF
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/dtd/web-app_2_2.dtd">
<web-app>
<display-name>Generic database Connector</display-name>
<description>
Connecting to a database using dataSource and OdbcDriver
Attributes as well as sending a query to the database;
</description>
<taglib>
<taglib-uri>/genericdbconnecttags.tld</taglib-uri>
<taglib-location>/WEB-INF/genericdbconnecttags.tld</taglib-location>
</taglib>
</web-app>
genericdbconnecttags.tld
C:\jakarta-tomcat-3.2.3\webapps\exper\WEB-INF
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>genericDBConnect</short-name>
<tag>
<name>dbconnect</name>
<tag-class>jsp.tags.dbase.genericDBConnect</tag-class>
<attribute>
<name>dataSource</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>odbcDriver</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
DBTester.jsp
Stored in:C:\jakarta-tomcat-3.2.3\webapps\exper
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Generic dataBase Connection</title>
</head>
<body>
<%@ taglib uri="/genericdbconnecttags.tld" prefix="database" %>
<database:dbconnect odbcDriver="sun.my.tag.lib" dataSource="hello">
this is the the begining of the end of life as we know it
</database:dbconnect>
</body>
</html>
And this is the error I get:
Error: 500
Location: /exper/DBtester.jsp
Internal Servlet Error:
org.apache.jasper.compiler.CompileException: C:\jakarta-tomcat-3.2.3\webapps\exper\DBtester.jsp(8,0) Unable to load class null
at org.apache.jasper.compiler.TagBeginGenerator.init(TagBeginGenerator.java:129)
at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.init(JspParseEventListener.java:759)
at org.apache.jasper.compiler.JspParseEventListener.addGenerator(JspParseEventListener.java:138)
at org.apache.jasper.compiler.JspParseEventListener.handleTagBegin(JspParseEventListener.java:909)
at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListener.java:194)
at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:825)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1077)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1042)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:209)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)
Please if you can help I will be very gratefulI was searching about this problem and I found here.
I'm using WSAD 4.0.3 and I'm making my first custom tag.
Here is my files:
======================= CLASS ======================
package sas.ric.tags.teste;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import java.io.IOException;
public class ClTagHello extends TagSupport {
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.println("HELLO!");
} catch (IOException ioe) {
System.out.println("Erro in ClTagHello: " + ioe);
return (SKIP_BODY);
================= TLD ==========================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>ric</short-name>
<uri></uri>
<info>Exemple</info>
<tag>
<name>hello</name>
<tag-class>sas.ric.tags.teste.ClTagHello</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
======================== JSP =====================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
</HEAD>
<%@ taglib uri="WEB-INF/app-tlds/tag-hello.tld" prefix="ric" %>
<BODY>
<ric:hello />
</BODY>
</HTML>
==========================================================
Please, help me.
Occur this error "JSPG0058E: Unable to load class null"
Thank's
Maybe you are looking for
-
VERY URGENT - NOT TALLYING OF RECON.A/C WITH THE TOTAL OF LINE ITEMS
Dear FI Experts, Since the total balances as per individual customers' balances ( thro FBL5N with one Recon a/c ) which is not tallied with Recon.GL for Local debtors if we see the same thro FS10N, please guide me immediately to reslove these proble
-
Hello I actually stole some of the text of this question from a previous post. The post hasn't had any activity for over a month, so I thought I would repost as I need a solution. I have modified it to my situation. I need to implement following scen
-
Why do the rulers (cmd R) disappear after using Print (cmd P) ?
Why do the rulers (cmd R) disappear after using Print (cmd P) ?
-
How to search documents without tags?
Is it possible to search documents without tags? Is there a search keyword or phrase, such as "not TAG", that we can use to search for the documents that are not attached with any tag? The OS being used is Yosemite. Many thanks
-
Photoshop c3 not seeing scanner in Import
Following an OS X 10.8.2 upgrade on my iMac, my Canon Pixma 495 scanner won't work with CS3 Photoshop. It no longer shows up under File/Import. Hopefully a minor tweak in Permissions can fix this, but I've seen nothing about it so far. Preview and