File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes faced error in jsp simple custom tag implemention Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "faced error in jsp simple custom tag implemention" Watch "faced error in jsp simple custom tag implemention" New topic
Author

faced error in jsp simple custom tag implemention

pedababu murala
Greenhorn

Joined: May 25, 2008
Posts: 1
please anybody could find why my application giving ServletException
The following are the source files
index.html

<html>
<body>
<form method="GET" action="http://localhost:8888/cust5/druginfo.do">
<table border="1" align="center">
<tr>
<td><select id="drugs" multiple size="7" style="width: 100;">
<option value="B4112">B4112</option>
<option value="OMEZ">OMEZ</option>
<option value="BCOMPLEX">BCOMPLEX</option>
<option value="AVIL">AVIL</option>
<option value="COLDACT">COLDACT</option>
</select></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>

web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>druginfo.do</servlet-name>
<servlet-class>HandlerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>druginfo.do</servlet-name>
<url-pattern>/druginfo.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>

<jsp-config>
<taglib>
<taglib-uri>http://thomson.pdi/tags</taglib-uri>
<taglib-location>/WEB-INF/simple.tld</taglib-location>
</taglib>
</jsp-config>

</web-app>

simple.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<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>
<jsp-version>1.2</jsp-version>
<uri>http://thomson.pdi/tags</uri>
<description>
Thomson custom tags
</description>
This is a dummy tag solely to satisfy DTD requirements
<tag>
<name>drugsinfo</name>
<tag-class>SimpleTagTest5</tag-class>
<body-content>scriptless</body-content>
<attribute>
<name>drugList</name>
<requried>true</requried>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>

HandlerServlet.java

import java.io.IOException;
import java.rmi.ServerException;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class HandlerServlet extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServerException{
res.setContentType("text/html");
String drugs[]=req.getParameterValues("drugs");
try{
req.setAttribute("durgs", drugs);
RequestDispatcher rd=req.getRequestDispatcher("/result.jsp");
rd.forward(req,res);
}catch(Exception e)
{
e.printStackTrace();
}
}
}

SimpleTagTest5.java

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class SimpleTagTest5 extends SimpleTagSupport{

private String[] drugList;

public void setDrugList(String[] drugList) {
this.drugList = drugList;
}
public void doTag()throws IOException,JspException{

for(String drug rugList){
getJspContext().setAttribute("drug",drug);
getJspBody().invoke(null);
}
}
}

result.jsp


<%@ taglib uri="http://thomson.pdi/tags" prefix="s"%>
<table border="2">
<caption>Drugs Information</caption>
<s rugsinfo drugList="${durgs}">
<tr>
<td>
${drug}
</td>
</tr>
</s rugsinfo>
</table>


Pedababu .M
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: faced error in jsp simple custom tag implemention
 
Similar Threads
cannot find the declaration of element taglib
Classic tags. browser is not responding.
problem with tld file
unable to initialize a list from custom simple tag handler
Custom tags Problem