Jsp&Servelet study notes (2)
Author:Eve Cole
Update Time:2009-07-02 17:15:08
1.2 Introduction to the first jsp program:
1. Open a text editor, or a jsp-specific text editor that can highlight some syntax.
2. If you write a jsp to handle http requests. It will be the same as writing an html file.
3. If a jsp file wants to contain some Jsp commands (such as a taglib), you must write < %@% > at the beginning of the file.
4. You can enter a normal form submission or user tag where you need it.
5. When saving the file, save it with a .jsp extension. Place it at the top level of the entire directory in a web application. both placed
In the same directory as Web-info.
Example:
// Represents the comment content <%-- --%>
<%-- use the 'taglib' directive to make the JSTL 1.0 core tags available; use the uri " http://java.sun.com/jsp/jstl/core " for JSTL 1.1 --%>//Use c :out tag http://www.downcodes.com/
<%@ taglib uri=" http://java.sun.com/jstl/core " prefix="c" %>
<%-- use the 'jsp:useBean' standard action to create the Date object; the object is set as an attribute in page scope --%>//Use javabean in jsp to indicate its (id) object and (java. util.Date) class.
<jsp:useBean id="date" class="java.util.Date" /> <html><head><title>First JSP</title></head><body><h2>Here is today's date< /h2>//Use expression to output ${data}
<c:out value="${date}" /> </body></html>
http://blog.csdn.net/bruceleey/archive/2007/02/07/1503844.aspx