Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

DYNAMICALLY ASSIGNING A VALUE TO DIRECTIVES  RSS feed

 
Amarnath Reddy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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>
 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make <rtexprvalue> true for the attribute id.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!