Write "pure HTML" jsp application - learn to use JSTL Release Date: 2004-05-11 Author: Juniper_c just started using JSP web applications do when, like to use PHP, ASP, like using JSP, mixed with a large in the HTML code Scriptlet --- Java code segment. Since I can "typeset" technology, I feel very good, write "efficiency" high, debugging and convenient! It later, I only knew that - this is an extremely stupid approach. When JSP is born, it has been clearly clarified with the ASP, PHP, using JavaBean, servlet can effectively put the java code in HTML. Segment peeling, then packaged into a "logical processing component" that can be reused in multiple pages - this is one of the advantages of JSP relative to PHP and ASP. But sometimes even if we use JavaBean servlet, we have to embed the "very small amount" Java code in HTML -, sometimes you have this: Because you can't use the implied object in JSP, For example, REQUEST, SESSION, RESPONS, etc. Work with Servlet, although JSP objects can be used, but can not be flexibly inserted into HTML in JavaBean. Its appearance completely solves this problem, allowing you to write "pure html" JSP page number - the benefits brought about by this self-evident: higher maintenanceability, higher component multiplexing efficiency , More easy to maintain the HTML page `` `` The younger brother is not talented, just start learning JSTL, I think this Dongdong is really good! I want to let more beginners know this, and can be applied to the actual web development. Below, we start writing our first TAG! ** The following is the JSP file using simple TAG, the result is the current time: <% @ Page ContentType = "text / html; charset = GB2312"%>
<% @ Taglib URI = "/ Tags "prefix =" VISA "%> The current time is:package tag; import java.util.Date; import javax.servlet.jsp *;. import javax.servlet.jsp.tagext *;. public class datetag extends TagSupport {public int doStartTag () throws JspException {Date dte = new Date ( ); TryContext.get (); out.print (dte);} catch (java.ioException e) {throw new jsptagexception (E.getMessage ());} return skip_body;}} with javac After compiling, you get the datetag.class file, put it in the XXX / Web-INF / CLASSES / TAG directory. 2 - Write a Tag library descriptor: tags.TLD is readily see that