An Introduction to Creating Java Cusom Tags for JSPs: IRAD

Tags:
Begin Custom End Exams Java Jsf Jsp Mock Pages Scbcd Scea Scja Scjp Scwcd Server Struts Tag Tags
javaprogrammingcbts
  • Affiliate Submitter:
    javaprogram...
  • International International
  • Comments: 0
  • Views: 119
  • Added: 05-Aug-08

You can watch the high resolution, full screen videos here:

http://www.thebookonhibernate.com/j2ee/index.jsp?link=07customtags

Creating Your Own Custom JSP Tags

This free, multimedia tutorial shows you how to use IBM's Rational Application Developer (IRAD) 6.0 to create a custom tag library (well, one custom tag, so it is a pretty impoverished library), and the corresponding Java code and tld file to make a custom tag work on a JSP page.

If you found something helpful here, please do your part and help support the site. Link to us, buy some books, support our sponsors, tell your developer friends about us, and remember: Happy Java!

package com.examscam.servlet.tags;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.examscam.common.Timer;


public class TimerTag extends TagSupport {


public int doStartTag() throws JspException {
JspWriter out = pageContext.getOut();
ServletRequest request = pageContext.getRequest();
ServletResponse response = pageContext.getResponse();
ServletContext application = pageContext.getServletContext();
HttpSession session = pageContext.getSession();

Timer t = (Timer)session.getAttribute("timer");
if (t==null){
t = new Timer();
session.setAttribute("timer", t);
}
try {
out.print("Elapsed Time: " + t.getElapsedTime());
out.print("Start Time: " + t.getStartTime());
} catch (IOException e) {

e.printStackTrace();
}

return SKIP_BODY;
}
}

Please check out my SCJA Java Certification Mock Exam website:

http://www.scja.com/associate/

And for Hibernate and JPA tutorials, check out:

http://www.thebookonhibernate.com

http://www.scja.com/j2ee/index.jsp?link=03httpsessionswf

  1. Categories: People & Stories
Comments on

An Introduction to Creating Java Cusom Tags for JSPs: IRAD

1 Comment | Add Comment 1 Comment | Add Comment