Custom Tag iteration
I'm a little new to this so hopefully my question isn't overly confusing.
I have a custom tag that iterates through a list of items and makes specific variables available to the jsp page which looks something like this.
<xcontent:getItems>
<tr bgcolor="<%=bgcolor%>">
<td>Name: <%=item_name%></td>
</tr>
</xcontent:getItems>I have a doStartTag, doInitBody and doAfterBody and normally my code all works fine. My issue is that sometimes I want to skip one of the items and not produce any output. If I want to skip Item #2 I just return EVAL_BODY_CONTENT without setting any variables (by calling pageContext.setAttribute). I properly get no output for Item #2 but I get Item #1 repeated. It appears that the tag tries to provide output everytime it reaches the return EVAL_BODY_CONTENT.
How can I get my code to skip an item entirely and basically only iterate the tag once even though there are 2 items and 2 return EVAL_BODY_CONTENT?
- Todd
You should either return SKIP_BODY_CONTENT or (if you want to see the empty items too), clear the value of the scripting variables. This is why item #1 is repeated.
Similar Messages
-
Simple question about custom tags really easy!!
I am trying to make my own custom tags, so far i have created simple one that have i use for heading or to set the page layout for a jsp page, My question is I want to make a custom tag with a body , with a start and end tag can anybody give a simple example of a custom tag which has a body.
I do not mean write me a tag i mean what could a tag with a body be used for? Can you give me some example of what a tag of this kind could do?Thanks having read that and some other pages i have another question:
would it be possible to put the following code into a custom tag so that i can pass in a list and have it output it to a table?
<TABLE >
<%
out.println("<TABLE >\n" +
"<TR BGCOLOR=\"#FFDDAA\">\n" +
" <TH>ID Number\n" +
" <TH>Artist\n"
Iterator it = pricePassed.getpricePassed().iterator();
while( it.hasNext() ){
MySite.VideoBean vids = (MySite.VideoBean) it.next();
out.println( "<TR>\n" +
"<TD><Center><B>" + vids.getRecId() + "</TD>" +
"<TD><Center><B>" + vids.getArtist() + "</TD>"
</TD></TR>\n" );
%></TABLE>At the moment i use the above in a jsp to put data into a table, would it be a massive task to undertake to put into a custom tag? -
Custom Tag -- Custom Component problems with iframes
I have a "project" component that originally iterated over a list of models and created/renderered the corresponding (and fairly complex) interactive UI components for those models. On the client-side, the output from these were then organized neatly into "tabs" via CSS ... all on one page. Since these UI Components are so hefty, when any iteraction was done on one of them, the whole page had to re-render and things got just plain slow. To get around this limitation, I decided to have my "project" component no longer create the UI components himself, but instead generate an IFRAME that points to a page that will generate a single component. This way, any iteraction will just cause that single IFRAME to refresh.
Due to the fact that an IFRAME can only be populated by using the src attribute, I have created a page that contains a JSF View (<faces:view>) and inside is a single custom tag of mine (<mine:displayView>). Let's call this page singleDisplayView.jsf. I create iframes that point to singleDisplayView.jsf with different request params for each (singleDisplayView.jsf?modelName=Foo, singleDisplayView.jsf?modelName=Bar, etc.)
The displayView tag has one attribute called requestQueryString and I use the tag like so:
<t:displayView requestQueryString="<%=request.getQueryString()%>" />The displayView tag's class is DisplayViewTag. In DisplayViewTag::setProperties(UIComponent uiComponent) method, I get the model name out of the request map and set this property on the UIComponent.
The problem is that I'm noticing that as the main page (that contains these frames) loads, setProperties() is only being called twice. After that, the components created by subsequent iframes just seem to be using the modelName from the second frame.
Is there a syncronization issue I don't understand?
Any ideas?
Any help would be much appreciated.
Thanks in advance,
MarkOn a possibly related note, I read this in an article of the JSF application lifecycle:
In the first phase of the JSF lifecycle -- restore view -- a request comes
through the FacesServlet controller. The controller examines the request and
extracts the view ID, which is determined by the name of the JSP page.Could it be that the lifecycle is trying to reuse components from a single view, since all these iframes are pointing to the same page? -
Controlling the output of custom tags
Hi everybody
I'm developing some special custom tags and I have a main tag and several nested ones. I want the nested ones to put their output String into JspWriter buffer when the main tag doEndTag() happens or use the JspWriter and print a sign when each nested tag are processed and then on doEndTag() of the main tag modify the buffer and replace the signs with their actual values. But so far I havn't got anywhere.
Because JspWriter doesn't allow manual modification of buffer and doesn't even let you to access the content of the biffer either all one can do is to print more String into the buffer!
Any suggestion would be a great help to me.
Thanks a lotHere's an example that saves up the bodies of the nested tags and prints them out when the main tag is finished.
index.jsp
<%@ taglib prefix="mytags" uri="/WEB-INF/mytags.tld" %>
<html>
<body>
<h1>index.jsp</h1>
<mytags:main>
<mytags:nested>value 1</mytags:nested>
<mytags:nested>second value</mytags:nested>
<mytags:nested>3RD VALUE</mytags:nested>
</mytags:main>
</body>
</html>mytags.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/j2ee/dtds/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>mytags</short-name>
<tag>
<name>main</name>
<tag-class>mytags.MainTag</tag-class>
<body-content>JSP</body-content>
</tag>
<tag>
<name>nested</name>
<tag-class>mytags.NestedTag</tag-class>
<body-content>JSP</body-content>
</tag>
</taglib>/mytags/MainTag.java
package mytags;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class MainTag extends TagSupport
public int doStartTag() throws JspException
LinkedList nesteds = new LinkedList();
pageContext.setAttribute("MainTagNesteds", nesteds);
return EVAL_BODY_INCLUDE;
public int doEndTag() throws JspException
JspWriter out = pageContext.getOut();
try {
LinkedList nesteds = (LinkedList)pageContext.getAttribute("MainTagNesteds");
Iterator iterator = nesteds.iterator();
while( iterator.hasNext() ) {
out.println( iterator.next() + "<br>" );
catch(IOException exc) {
exc.printStackTrace();
return EVAL_PAGE;
}/mytags/NestedTag.java
package mytags;
import java.util.LinkedList;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class NestedTag extends BodyTagSupport
public int doAfterBody() throws JspException
BodyContent bc = getBodyContent();
String bodyAsString = bc.getString();
LinkedList nesteds = (LinkedList)pageContext.getAttribute("MainTagNesteds");
nesteds.add( bodyAsString );
return SKIP_BODY;
-
Passing Values back from Custom Tag
I'm using custom tags, and I'm trying to pass back values to the JSP page from a tag which is iterating over values it gets from an Array. But for some reason I can't access the values.
Here is the Tag:
public class MemberHelper extends TagSupport implements IterationTag {
private Iterator iterator;
protected Tag parent;
protected PageContext pageContext;
public MemberHelper() {
super();
public void otherDoStartTagOperations() {
sfmember_prop_desc desc = new sfmember_prop_desc();
ArrayList allt = new ArrayList();
try {
allt = desc.GetAllCustom();
} catch (java.sql.SQLException ex) {}
if(allt.size() > 0)
iterator = allt.iterator();public void otherDoEndTagOperations() {
public boolean shouldEvaluateRestOfPageAfterEndTag() {
return true;
public int doStartTag() throws JspException, JspException {
otherDoStartTagOperations();
if (theBodyShouldBeEvaluated()) {
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
public int doEndTag() throws JspException, JspException {
otherDoEndTagOperations();
if (shouldEvaluateRestOfPageAfterEndTag()) {
return EVAL_PAGE;
} else {
return SKIP_PAGE;
public int doAfterBody() throws JspException {
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY; -
Sub components problem in custom tag
Hi!
Im writing custom tag that do nothing but can contains other components.
So first I create custom tag with hendler that extends UIComponentTag and component class that extends UIComponentBase
now tag work but i dont see sub components on the page
Second i override encodeChildren and getFamily methods with:
public String getFamily() {
return "MyCaller";
public void encodeChildren(FacesContext context) throws IOException {
Iterator ch=this.getChildren().iterator();
while(ch.hasNext()){
UIComponent oKid = (UIComponent)ch.next();
if(oKid.isRendered()){
oKid.encodeBegin(context);
oKid.encodeChildren(context);
oKid.encodeEnd(context);
super.encodeChildren(context);
}But subcomponents not rendered on page.
So are you know whats wrongthe problem was in wrong getComponentType() that return wrong value
-
Unwanted body evaluation of a custom tag
Following custom tag should output:
[Tag Test]
a
b
c
This is another test
a
b
c
This bad boy!
a
b
c
But, in reality, the output is as follows:
[Tag Test]
a
b
c
This is another test
c
a
b
c
This bad boy!
c
a
b
c
As you can see, everytime the tag is executed, unwanted body evaluation has occured before the assignment to a page-scope variable. What coud be the cause of the problem?
/* tag handler */
package mytag;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import javax.servlet.http.*;
import java.util.*;
public class foreach extends BodyTagSupport{
private Iterator iterator;
private String group;
public void setGroup(String group){
this.group = group;
public String getGroup(){
return group;
public int doStartTag() throws JspException{
try{
String[] intarray = new String[] {"a","b","c"};
ArrayList ar = new ArrayList(Arrays.asList(intarray));
iterator = ar.iterator();
if (iterator.hasNext()){
return EVAL_BODY_BUFFERED;
else{
return SKIP_BODY;
catch (Exception e){
System.err.println(e);
return SKIP_BODY;
public int doAfterBody() throws JspException{
try{
if (iterator == null){
return SKIP_BODY;
if (iterator.hasNext()) {
String o = (String)iterator.next();
pageContext.setAttribute("a1", o);
return EVAL_BODY_AGAIN;
else{
return SKIP_BODY;
catch (Exception e){
System.err.println(e);
return SKIP_BODY;
public int doEndTag() throws JspException {
try {
pageContext.getOut().print(bodyContent.getString());
catch(Exception ioe) {
System.out.println(ioe);
return EVAL_PAGE;
--test.jsp---
<%@ page contentType="text/html" %>
<%@ taglib prefix="jrun" uri="/WEB-INF/mytag.tld" %>
<html><body bgcolor="lightgreen">
<hr>
[Tag Test]<br>
<jrun:foreach group="itemsql">
${a1}<br>
</jrun:foreach>
<hr>
This is another test<br>
<jrun:foreach group="itemsql">
${a1}<br>
</jrun:foreach>
<hr>
This bad boy!<br>
<jrun:foreach group="itemsql">
${a1}<br>
</jrun:foreach>
<hr></body></html>
--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></short-name>
<description>
</description>
<tag>
<name>foreach</name>
<tag-class>mytag.foreach</tag-class>
<body-content>JSP</body-content>
<description>
</description>
<attribute>
<name>group</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>Never mind. I've found the cause of my problem. I shoud hava started the iterator in the doStartTag() metod instead of in the doAfterBody().
-
Custom Tag and CFC : Nate Weiss
Hi,
being a beginner I'm trying with some marginal degree of
success to understand CFC's and Custome Tags.
In the CFMX7 W.A.C.K. There is an example shopping cart. This
start off as a basic affair then expands into more object based
principles using a custom tag add products to the cart
(ShoppingCart.cfc) and later on the same page uses a custome Tag to
display the cart items, calling it once for each item to display.
I am using the MVC structure under Fusebox 4, so this method
of using the same template, (reloading etc) is alien to me as with
MVC you usually have the data type intructions in different files
(anyway, I digress)
Now that I have the thing adding products and generally
working with my "shop", I thought about having a "special offer"
facility. With these "Hot Deals" being stored in another database
table, with their productID and new price.
However, obviously the shopping cart needs to be made aware
of this. With I would have thought an extra variable in the array
telling the custom tag to retrieve the special price and the
product information using a diufferent inner join query to normal.
I have attemtped this by adding an additional URL parameter
thus /..../HSOP/Y ("Has Special Offer Price" being set to "Y")
When this reloads the page the CFC invoke is set thus
<CFIF IsDefined("URL.HSOP") AND #URL.HSOP# EQ "Y">
<CFINVOKE
COMPONENT="#SESSION.MyShoppingCart#"
METHOD="Add"
MERCHID="#URL.AddMerchID#"
SOPH="Y">
<cfelse>
This successfully passes
Add(SOPH = Y, MERCHID = xxxx)
to the CFC. However I get this error......,
..................Element SOPH is undefined in ARGUMENTS.
the CFC simpley isnt adding the new variable to the array...
I think... it wont do a CFDump so there is no way of telling
<CFFUNCTION
NAME="Add"
HINT="Adds an item to the shopping cart">
<!--- Three Arguments: MerchID, Quantity and SOPH (flag
to state if there is a special price) --->
<CFARGUMENT NAME="MerchID" TYPE="numeric"
REQUIRED="Yes">
<CFARGUMENT NAME="Quantity" TYPE="numeric" REQUIRED="No"
DEFAULT="1">
<CFARGUMENT NAME="SOPH" type="string">
<!--- Get structure that represents this item in cart,
--->
<!--- then set its quantity to the specified quantity
--->
<CFSET CartItem = GetCartItem(MerchID)>
<CFSET CartItem.Quantity = CartItem.Quantity +
Arguments.Quantity>
<CFSET CartItem.SOPH = Arguments.SOPH>
</CFFUNCTION>
I cant see why this wouldn't create the variable
"CartItem.SOPH" and set it to "Y" as passed to it.
I notice the CFC performs an iteration of sorts to put the
cart items into an array. But I'm afraid I cant fathom what this
problem might be.
Any ideas. I have attached the whole CFC code (post editing
by me)
MAny thanks and Happy new YearHi,
As for me, I am testing the related pdf-417 barcode scanner these days. Do you have any ideas about it? Or any good suggestion? I am totally a green hand on barcode field. Any suggestion will be appreciated. Thanks in advance.
Best regards,
Arron -
Build-time errors with custom tags in wkshop sp3
We have custom tags which create tag variables declared in the .tld file as follows:
<tag>
<name>contentsIterator</name>
<tag-class>org.cap.documentaccess.taglibs.ContentsIteratorTag</tag-class> <tei-class>org.cap.documentaccess.taglibs.ContentsIteratorTEI</tei-class>
<body-content>JSP</body-content>
<display-name>Contents Iterator</display-name>
<description>
</description>
<variable> <name-from-attribute>id</name-from-attribute> <variable-class>org.cap.documentaccess.Content</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
</variable>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>
</description>
</attribute>
The calling jsp contains the following:
<cap:contentsIterator id="content">
The app built fine in wkshop(sp2) but in sp3 we get the following:
A name-from-attribute variable cannot reference a tag attribute that is request time or is not required.
Has the sp3 compiler become less forgiving or was this an oversight in sp2?if u are using weblogic workshop for ur application import c.tld into WEB-INF
and just import standard.jar, jstl.jar to WEB-INF/lib.
if u are using other than weblogic work shop like tomcat
1.just copy c.tld to WEB-INF.
2.create a 'lib' directoty inside WEB-INF copy standard.jar,jstl.jar files to that lib directory.
i think it should work. -
Hi all,
Is there a custom tag available for rendering packages off all classes loaded in a classloaders into a tree?
I already have an iterator containing the wanted packages.
Thanks in advance for your help,
Kind regardsI'm trying out the JSP tree tag library from Guy Davis at http://www.guydavis.ca/projects/oss/tags/
Does anyone know a performant algoritm to loop over a collection like the following :
x.y.Class1
x.y.z.Class2
x.y.z.Class3
x.Class4
Class5
All classes have to recieve a level to add in the tree.
Any idea's?
Kind regards, -
Utilizing Custom Tags to create a dynamic drop-down menu
Hi to all,
I am looking to create a dynamic .jsp to display to the user a drop-down list. This list is based upon data in database. The data will be passed as an application bean. This list will vary depending on application criteria.
I would like to use a custom tag to create the drop-down menu. I am attempting to keep the .jsp page strictly .jsp, no Java. (I have been successful in creating & using an iterator tag.)
Can someone point me in the right direction, or give me an example?
thanks!
Susie in Virginia BeachWhat exactly is it you don't know how to do? Write a custom tag or write database access code?
-
Why doesn't my custom tag work?
First, my backend database is MS Access. Nothing I can do about that, unfortunately.
I have defined three custom tags (no body, no attributes) to display report information from my project tracking/metrics Access database:
<prefix:showProjectInfo />
<prefix:showProjectTeam />
<prefix:showProjectHistory />
In my JSP, the first tag I use, <prefix:showProjectInfo />, works perfectly. However, <prefix:showProjectTeam /> gives no output.
First, here is the tld file that defines the tags (report.tld):
<?xml version="1.0" encoding="UTF-8" ?>
<!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>report</short-name>
<uri>/report</uri>
<!-- Forte4J_TLDX: This comment contains code generation information. Do not delete.
<tldx>
<tagHandlerGenerationRoot>classes</tagHandlerGenerationRoot>
</tldx>
-->
<!-- A validator verifies that the tags are used correctly at JSP
translation time. Validator entries look like this:
<validator>
<validator-class>com.mycompany.TagLibValidator</validator-class>
<init-param>
<param-name>parameter</param-name>
<param-value>value</param-value>
</init-param>
</validator>
-->
<!-- A tag library can register Servlet Context event listeners in
case it needs to react to such events. Listener entries look
like this:
<listener>
<listener-class>com.mycompany.TagLibListener</listener-class>
</listener>
-->
<tag>
<name>showProjectInfo</name>
<tag-class>mil.usaf.rad.metrics.report.showProjectInfoTag</tag-class>
<body-content>empty</body-content>
<description>Shows the basic project information</description>
</tag>
<tag>
<name>showProjectTeam</name>
<tag-class>mil.usaf.rad.metrics.report.showProjectTeamTag</tag-class>
<body-content>empty</body-content>
</tag>
<tag>
<name>showProjectHistory</name>
<tag-class>mil.usaf.rad.metrics.report.showProjectHistoryTag</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>Next, here is the relevant section of web.xml that defines this taglib:
<taglib>
<taglib-uri>/WEB-INF/report.tld</taglib-uri>
<taglib-location>/WEB-INF/report.tld</taglib-location>
</taglib>Next, the code for showProjectTeamTag.java:
* showProjectTeam.java
* Created on March 9, 2005, 10:46 AM
package mil.usaf.rad.metrics.report;
import java.io.*;
import java.sql.*;
import java.lang.Integer;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
* @author jason.ferguson
public class showProjectTeamTag extends TagSupport
public showProjectTeamTag()
super();
public int doAfterBody() throws JspException
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
int pr_id = Integer.parseInt(req.getParameter("pr_id"));
JspWriter out = pageContext.getOut();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
out.print("test");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:Metrics");
catch (Exception e)
throw new JspException(e.getMessage());
String queryGetTeam = "SELECT Projects.pr_id, Accounts.name AS Name, Sum(Schedule.hours) AS SumOfhours FROM tblTAAccounts AS Accounts INNER JOIN ((tblTAScheduleEntries AS Schedule INNER JOIN tblProjectRelease AS ProjectRelease ON Schedule.projectID = ProjectRelease.tblFKTimeAccntProject) INNER JOIN tblPMProjects AS Projects ON ProjectRelease.Release_ID = Projects.pr_id) ON Accounts.accountID = Schedule.accountID WHERE Projects.pr_id=" + pr_id + " GROUP BY Projects.pr_id, Accounts.name, ProjectRelease.Release_number, Projects.Project_name";
try
out.print(queryGetTeam);
stmt = conn.createStatement();
rs = stmt.executeQuery(queryGetTeam);
if (rs == null)
out.print("No Results!");
out.print("<table>\n");
out.print("<tr>\n");
out.print("<th>Name</th>\n");
out.print("<th>Total Hours</th>\n");
out.print("</tr>\n");
while(rs.next())
out.print("<tr>\n");
out.print("<td>" + rs.getString("Name") + "</td>\n");
out.print("<td>" + rs.getInt("SumOfhours") + "</td>\n");
out.print("</tr>\n");
out.print("</table>\n");
rs.close();
stmt.close();
conn.close();
catch (Exception e)
throw new JspException(e.getMessage());
return SKIP_BODY;
}Finally, projectdetail.jsp, where the tag is called:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="java.lang.Integer" %>
<%@taglib uri="/WEB-INF/report.tld" prefix="report" %>
<html>
<head><title>Project Detail</title></head>
<body>
<h1 align="center">Project Status</h1>
<h3>Project Description</h3>
<report:showProjectInfo />
<h3>Team Members</h3>
<report:showProjectTeam />
</body>
</html>The first tag, <report:showProjectInfo />, works fine. However, I get no output whatsoever when the system encounters <report:showProjectTeam />. I am a relative newbie at this, so any help is appreciated.
JasonIt doesnt seem to matter if the code is in doStartTag(), doEndTag(), orr any of the other functions.
I also put, as the first item in the function:
System.out.println("TEST");Nothing.
Just as an aside, here is the code for the <prefix:showProjectInfo />. Maybe I made a mistake in it? I closed the resultset and connection...
import java.io.*;
import java.sql.*;
import java.lang.Integer;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
* @author jason.ferguson
public class showProjectInfoTag extends BodyTagSupport
public int doEndTag() throws JspException
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
int pr_id = Integer.parseInt(req.getParameter("pr_id"));
JspWriter out = pageContext.getOut();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:Metrics");
catch (Exception e)
throw new JspException(e.getMessage());
String queryProjectInfo = "SELECT * FROM tblPMProjects WHERE pr_id=" + pr_id;
try
stmt = conn.createStatement();
rs = stmt.executeQuery(queryProjectInfo);
while (rs.next())
out.print("<table border=\"1\" style=\"border-collapse:collapse\">\n");
out.print("<tr>\n");
out.print("<td><b>Project Name:</b>" + rs.getString("Project_name") + "</td>\n");
out.print("<td align=\"right\"><b>RAD Number:</b>" + rs.getString("tblProjectNumber") + "</td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td>Project description: " + rs.getString("Project_description") + "</td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td>Customer: " + rs.getString("Customer_POC") + "</td>");
out.print("<tr>\n");
out.print("<tr>\n");
out.print("<td>Customer Unit: " + rs.getString("Customer_OFC") + "</td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td>Customer Phone: " + rs.getString("Customer_phone") + "</td>\n");
out.print("</tr>\n");
out.print("</table>\n");
rs.close();
stmt.close();
conn.close();
catch (Exception e)
throw new JspException(e.getMessage());
finally
//conn.close();
return SKIP_BODY; -
Weblogic Commerce Server 3.5 runtime failure in custom tag
An error occurred:
javax.servlet.ServletException: runtime failure in custom tag 'process'
at jsp_compiled._tools._property._propset_create._jspService(_propset_create.java:641)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:149)
at com.beasys.commerce.foundation.flow.ServletDestinationHandler.handleDestination(ServletDestinationHandler.java:51)
at com.beasys.commerce.foundation.flow.FlowManager.service(FlowManager.java:540)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1127)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1529)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)I just started getting this error after a year in production environment without any problems. Did you every find out what caused this or better yet how to prevent this?
Dan.
-
Hi, can anyone advise as to whether my tag library code (based
on Apache Jakarta Project) will actually achieve connection
pooling functionality across my entire JSP based application? I
am slightly concerned that my OracleConnectionCacheImpl object
may exist multiple times, hence rendering my conection pooling
attempt useless.
package com.solved.tag.dbtags.connection;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspTagException;
import javax.sql.DataSource;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import oracle.jdbc.pool.OracleConnectionCacheImpl;
* <p>JSP tag connection, used to get a
* java.sql.Connection object.</p>
* <p>JSP Tag Lib Descriptor
* <pre>
* <name>connection</name>
<tagclass>com.solved.tag.dbtags.connection.ConnectionTag</t
agclass>
* <bodycontent>JSP</bodycontent>
<teiclass>com.solved.tag.dbtags.connection.ConnectionTEI</t
eiclass>
* <info>Opens a connection based on a jndiName.</info>
* <attribute>
* <name>id</name>
* <required>true</required>
* <rtexprvalue>false</rtexprvalue>
* </attribute>
* </pre>
* @author Matt Shannon
public class ConnectionTag extends TagSupport {
static private OracleConnectionCacheImpl cache = null;
public int doStartTag() throws JspTagException {
try {
Connection conn = null;
if (cache == null) {
try {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup
("jdbc/pool/OracleCache");
cache = (OracleConnectionCacheImpl)ds;
catch (NamingException ne) {
throw new JspTagException(ne.toString());
conn = cache.getConnection();
pageContext.setAttribute(getId(),conn);
catch (SQLException e) {
throw new JspTagException(e.toString());
return EVAL_BODY_INCLUDE;
package com.solved.tag.dbtags.connection;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.jsp.tagext.TagSupport;
* <p>JSP tag closeconnection, used to close the
* specified java.sql.Connection.<p>
* <p>JSP Tag Lib Descriptor
* <pre>
* <name>closeConnection</name>
<tagclass>com.solved.tag.dbtags.connection.CloseConnectionTag&
lt;/tagclass>
* <bodycontent>empty</bodycontent>
* <info>Close the specified connection. The "conn"
attribute is the name of a
* connection object in the page context.</info>
* <attribute>
* <name>conn</name>
* <required>true</required>
* <rtexprvalue>false</rtexprvalue>
* </attribute>
* </pre>
* @author Matt Shannon
* @see ConnectionTag
public class CloseConnectionTag extends TagSupport {
private String _connId = null;
* The "conn" attribute is the name of a
* page context object containing a
* java.sql.Connection.
* @param connectionId
* attribute name of the java.sql.Connection to
close.
* @see ConnectionTag
public void setConn(String connectionId) {
_connId = connectionId;
public int doStartTag() {
try {
Connection conn = (Connection)pageContext.getAttribute
(_connId);
conn.close();
} catch (SQLException e) {
// failing to close a connection is not fatal
e.printStackTrace();
return EVAL_BODY_INCLUDE;
public void release() {
_connId = null;
package com.solved.tag.dbtags.connection;
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
* TagExtraInfo for the connection tag. This
* TagExtraInfo specifies that the ConnectionTag
* assigns a java.sql.Connection object to the
* "id" attribute at the end tag.
* @author Matt Shannon
* @see ConnectionTag
public class ConnectionTEI extends TagExtraInfo {
public final VariableInfo[] getVariableInfo(TagData data)
return new VariableInfo[]
new VariableInfo(
data.getAttributeString("id"),
"java.sql.Connection",
true,
VariableInfo.AT_END
data-sources.xml:
<?xml version="1.0"?>
<!DOCTYPE data-sources PUBLIC "Orion data-
sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd">
<data-sources>
<data-source
class="oracle.jdbc.pool.OracleConnectionCacheImpl"
name="jdbc/pool/OracleCache"
location="jdbc/pool/OracleCache"
url="jdbc:oracle:thin:@oracle1:1521:pdev"
>
<property name="maxLimit" value="15" />
<property name="cacheScheme" value="2" />
<property name="user" value="console" />
<property name="password" value="console" />
<description>
This DataSource is using an Oracle-native DataSource Class so as
to allow Oracle Specific extensions.
A getConnection() call on this DataSource will return
oracle.jdbc.driver.OracleConnection.
The connection returned is a logical connection.
The caching scheme in place is Fixed Wait. Refer below to
possible values.
Dynamic 1
Fixed Wait 2
Fixed Return Null 3
</description>
</data-source>
</data-sources>
many thanks,
Matt.Hi. Show me your pool definition.
Joe
Ramamurthy wrote:
I am using the jsp custom tag library from BEA called sqltags.tld which came with Weblogic 5.1. Currently I am using Weblogic6.1 sp2 on Solaris.
I have created a Connection Pool for Sybase database using the driver com.sybase.jdbc.SybDriver.
When I created jsp page to connect to the connection pool using sqltags custom tag library, I am getting the error
"javax.servlet.jsp.JspException: Failed to write body content
at weblogic.taglib.sql.ConnectionTag.doAfterBody(ConnectionTag.java:43)
at jsp_servlet.__hubwcdata._jspService(__sampletest.java:1014)"
After this message, whenever I try to access the same jsp page I am getting the message
"javax.servlet.jsp.JspException: Failed to load JDBC driver: weblogic.jdbc.pool.D
river
at weblogic.taglib.sql.ConnectionTag.doStartTag(ConnectionTag.java:34)
at jsp_servlet.__hubwcdata._jspService(__sampletest.java:205)".
Can you please help me the reason why this problem is happening and how to fix this ?
This problem doexn't happen consistently. This occurs once in a while.
I tried to increase Login delay Seconds parameter in the Connection Pool to 15 sec. It didn't help me much.
Thanks for your help !!!
Ram -
Is possible to write a custom tag inside another custom tag ??
Hi
I�m trying to reduce the time needed to code mi app presentation layer, it uses some custom tags with certain configuration, i would like to know if its possible to do something like this inside my custom tag doAfterBody().
public int doAfterBody() throws JspException {
JspWriter writer=bodyContent.getEnclosingWriter();
try {
writer.print("<customTag:myAnotherTag someEspecificConfigurationParams="someEspecificValues"/>");
} catch (IOException e) {
pageContext.getServletContext().log("Error: "+e.getMessage());
}return SKIP_BODY;
}The goal is to simplify the jsp code because the configuration params for the custom tags (css styles and similar) are allways the same.
That don�t work, it simply prints <customTag:myAnotherTag/> in screen but the tag is not evaluated, i�ve tried too something like
public int doAfterBody() throws JspException {
if (repeat) {
JspWriter writer = bodyContent.getEnclosingWriter();
try {
writer.print("<customTag:myAnotherTag/>");
} catch (IOException e) {
pageContext.getServletContext().log("Error: " + e.getMessage());
repeat = false;
return EVAL_BODY_AGAIN;
return SKIP_BODY;
}And it doesn�t worked worked. Maybe using the taghandler classes and calls to the doAfterBody could make it work, but when you need to nest tags it could be a little hell of coupling calls, so before doing it i would like to know if what i want is possible. After reading some books i tought it could work because the stack of out objects, but i can�t make it work.
Another idea is to inherit from tagHandler and override some properties in the tags, but i don�t like the idea to much.
So, can anyone help me??
Thanks.You cannot do that and I have listed out the reason and a possible solution in this post http://forum.java.sun.com/thread.jspa?threadID=697243 from yesterday.
cheers,
ram.
Maybe you are looking for
-
How call procedure or package from Oracle BI Publisher 10.1.3.2.1
Hi Gurus, I need to call a procedure or package from Oracle BI Publisher 10.1.3.2.1 by passing parameters, I do it because it would be easier to fill a table as the report that asks for is too complex (8 breaks, 5 dblinks, 20 tables, etc). I'm not us
-
Partition External HDD and questions about mac
Hey Forum, I am using Mac OS X snow leopard on my macbook, and I recently bought a WD HDD 500gb external. I was wondering is 320gb for mac and 125 gb for windows enough? Pls reply. Thanks Ala.
-
Sync Error in lite 10g.
Im getting the following error when sync. ???? Cant trace it please help Sync session exception stack trace: java.sql.SQLException: ORA-00932: inconsistent datatypes: expected DATE got NUMBER at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.
-
I've seen a few people having this problem but haven't seen a solution that works. Spece/tech details are... Windows 8 Pro 64Bit 32Gb Ram 1TB+ free space Intel I7 3820CPU Nvidia GTX 560Ti GPU Master Suite CS6 All Software/OS updates applied. I am try
-
I just downloaded a new version of OS7 to my iphone and when I try to sync with my mac book pro it will not finish and just spins around at the last step. anyone help?