Java Server Pages, a server side technology which embeds java into html pages. 2 Custom Tags A custom tag is a user-defined JSP tag. Custom tags have a rich set of features. They can [JavaWS] Be customized via attributes passed from the calling page. Access all the objects available to JSP pages. Modify the response generated by the calling page. Communicate with each other. You can create and initialize a JavaBeans component, create a variable that refers to that bean in one tag, and then use the bean in another tag. Be nested within one another, allowing for complex interactions within a JSP page. To use a custom tag, you check and make sure there is a tag library description (.tld) file. You could either create a custom tag by your self, or download predefined custom tags. check and make sure that the tag implementation files (.class files or .jar file) are either in your webapps/WEB-INF/classes (if they are .class files), or in webapps/WEB-INF/lib (if they are jar files). at the beginning of your jsp file, add a directive to tell the jsp container that you are going to use a customer tag. You have two options, first, use the URI of the .tld file as follows <%@ taglib uri="/WEB-INF/tutorial-template.tld" prefix="tt" %>, or you could do it in directly by first defining a taglib item in your web.xml file (web.xml file is in $SERVLET_HOME/webapps/yourappname/WEB-INF/), and then use the short name of that .tld file: <taglib> <taglib-uri>/tutorial-template</taglib-uri> <taglib-location> /WEB-INF/tutorial-template.tld </taglib-location> </taglib> <%@ taglib uri="/tutorial-template" prefix="tt" %> depending on how your custom tag has been defined, you could use either of the following formats in your .jsp file: <tt:simple /> <tt:tag attrname=attrvalue> body </tt:tag> 3 How to I pass objects between jsp and servlet? Use request.setAttribute and request.getAttribute On one side: request.setAttribute("name",object); and on the other side : request.getAttribute("name"); Comments References[JavaWS] http://java.sun.com/webservices/docs/1.0/tutorial/doc/JavaWSTutorialTOC.html
A custom tag is a user-defined JSP tag. Custom tags have a rich set of features. They can [JavaWS]
<%@ taglib uri="/WEB-INF/tutorial-template.tld" prefix="tt" %>
<taglib> <taglib-uri>/tutorial-template</taglib-uri> <taglib-location> /WEB-INF/tutorial-template.tld </taglib-location> </taglib> <%@ taglib uri="/tutorial-template" prefix="tt" %>
<%@ taglib uri="/tutorial-template" prefix="tt" %>
<tt:simple /> <tt:tag attrname=attrvalue> body </tt:tag>
<tt:tag attrname=attrvalue> body </tt:tag>
3 How to I pass objects between jsp and servlet? Use request.setAttribute and request.getAttribute On one side: request.setAttribute("name",object); and on the other side : request.getAttribute("name"); Comments References[JavaWS] http://java.sun.com/webservices/docs/1.0/tutorial/doc/JavaWSTutorialTOC.html
Use request.setAttribute and request.getAttribute
On one side: request.setAttribute("name",object);
and on the other side : request.getAttribute("name");
References[JavaWS] http://java.sun.com/webservices/docs/1.0/tutorial/doc/JavaWSTutorialTOC.html