• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DYNAMICALLY ASSIGNING A VALUE TO DIRECTIVES

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PLEACE SOVE THIS PROBLEM URGENTLY.I HAVE BEEN USING WEBLOGIC TO WORK WITH TAG LIBS.
1> IN WEBLOGIC SERVER I HAVE CREATED A DIRECTORY CALLED 'WEB- INF' UNERE c:\weblogic\myserver\public_html AND I COPIED THE '.tld' FILE THERE.
i.e., c:\weblogic\myserver\public_html\WEB-INF\.tld
2> I COPIED THE .html FILES UNDER c:\weblogic\myserver\public_html\.html
3> I PLACED MY .class FILES UNDER THE c:\weblogic\myserver\serveltclasses\taglib\myexamples\.class
/** THIS PROGRAM IS USED TO DEMONSTRATE HOW TO IMPLEMENT THE */
/******INTAG************************************************/
package taglib.test;
import java.sql.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.IOException;
public class AttributeTag extends TagSupport
{
public int qty=0;
public String id;
Connection con;
PreparedStatement pstmt;
ResultSet rs;
String query;
public void setQty(String qty)
{
this.qty=new Integer(qty).intValue();
}
public void setStore(String id)
{
this.id=id;
}
public int doStartTag()throws JspException
{
try{
pageContext.getOut().print("<center><h2>doStartTag() Excecuted</h2></center>");
}catch(IOException ioe){throw new JspException(ioe.getMessage());}
return EVAL_BODY_INCLUDE;
//return SKIP_BODY;
}
public int doEndTag()throws JspException
{
try{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:reddy","scott","tiger");
pstmt=con.prepareStatement("select * from stores where qty>=? and stor_id=?");
pstmt.setInt(1,qty);
pstmt.setString(2,id);
rs=pstmt.executeQuery();
pageContext.getOut().print("<TABLE border='5' bgcolor='yellow'>");
while(rs.next())
{
pageContext.getOut().print("<tr>");
pageContext.getOut().print("<td><h2>"+rs.getString("ord_num")+"</h2></td>");
pageContext.getOut().print("<td><h2>"+rs.getString("ord_date")+"</h2></td>");
pageContext.getOut().print("<td><h2>"+rs.getInt("qty")+"</h2></td></tr>");
}
pageContext.getOut().print("</TABLE>");
}catch(Exception e){pageContext.getOut().print(e.getMessage());}
}catch(IOException ioe){ioe.getMessage();}
return EVAL_PAGE;
}
}
/***************************************************************/
/*JSP FILE WHRE I AM USING THE TAGLIB*************************/
<%@ page language="java" %>
<html>
<body>
<%! String itemCode;%>
<%
itemCode=request.getParameter("itemCode");
%>
<%=itemCode%>
<%@ taglib prefix="amar" uri="/AttributeTag.tld" %>
<amar:attribute qty="8" id="<%=itemCode%>"/>
//HRERE ACTUALLY I AM GETTING THE COMPILATION ERROR.WHEN I AM TRYING TO ASSIGN THE VALUE DYNAMICALLY IT'S GIVING COMPILATION ERROR.
<h1>Tag Exceuted</h1>
</body>
</html>
//**********************************************************////
//*************.tld FLIE **********************************///<
<?xml version="1.0"?>
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>Athene Tag Samples</shortname>
<tag>
<name>attribute</name>
<tagclass>taglib.test.AttributeTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>qty</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
make <rtexprvalue> true for the attribute id.
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic