... to general response page } Using Request Properties • Example: Sending custom image types – Send .png image if supported – Send .jpg image otherwise String imagetypes = request.getHeader(“Accept”); boolean ... display response as Excel spreadsheet – response.setContentType(“application/vnd.ms-excel”); – Send response back in simple format: • Cells in same row separated by tab ‘\t’ • Move t...
Ngày tải lên: 14/07/2014, 16:00
... library 22 Commenting JSP Files • Crucial to future maintenance of site • Inside of JSP code (between <% and %>): // comment /* comment */ • Outside of JSP code (that is, in html) <! comment > 8 JSP ... 10 JSP Scoping • Variable declared in a block of JSP on a page • May be accessed by any other JSP on same page • No access to variable from any ... middle) 17 Ha...
Ngày tải lên: 14/07/2014, 16:00
Bài Giảng Lập Trình JSP _P4
... MULTIPLE> • Sends name=value string for each option selected …peripherals=camera&peripherals=scanner… • getParameter method will not work! 7 Example Result 9 Checkbox JSP • If execute JSP code: String ... monitor is checked – No mention of monitor if not checked 10 Conditions in Java • JSP may need to do different things depending on checkbox – Display “Monitor” if checked – Di...
Ngày tải lên: 14/07/2014, 16:00
Bài Giảng Lập Trình JSP _P5
... etc.). – Decide which JSP should be sent back as response. – Forward control (and request data) to that JSP. request Control servlet JSP response JSPs act as views JSP JSP Servlet Details • Important ... JSP) – Methods invoked by a request for the servlet – Usually redirects to a JSP Tomcat Request for servlet Servlet Servlet methods called JSP Redirect to appropriate respo...
Ngày tải lên: 14/07/2014, 16:00
Bài Giảng Lập Trình JSP _P6
... context.getInitParameter(“name"); • Accessing from a JSP: – String value = application.getInitParameter(“name"); Built-in object in JSP (like “request”) Context Parameters Form of xml tag Welcome ... Parameters Form of xml tag Welcome Page Properties • Page shown at webapp startup – Default: index .jsp • Can change to a new welcome file Configuration Files • Each webapp has a...
Ngày tải lên: 14/07/2014, 16:00
Bài Giảng Lập Trình JSP _P7
... Messages in JSP Calendar Dates in Java • Construct a new GregorianCalendar object – Contains information about current date when created – Must import java.util.* library • Use get(Calendar.fieldname) ... approach: Force JSP to repeat validation done in servlet to determine which messages to display • Better approach: Once servlet detects error, it creates error message and passes to...
Ngày tải lên: 14/07/2014, 16:00
Bài Giảng Lập Trình JSP _P8
... other JSPs test whether attribute is null • If so, redirect to another page – Initial page in sequence – Error page telling session has expired • Syntax for redirection from JSP: < ;jsp: forward ... Data • Servlets/JSPs can store data associated with session ID • Servlets/JSPs can look up that data in future when passed the session ID in request Server session ID Client data Servlet or...
Ngày tải lên: 14/07/2014, 16:00
Bài Giảng Lập Trình JSP _P9
... list Used together to loop through and show all Items on “shopping cart” page Getting Cost in JSP Order Class Business Model Objects Key idea: • Methods in model objects should implement business ... set/get quantity – Method to get total cost of order • Computed from quantity here instead of in JSP/ servlet – Method to check whether quantity valid in terms of business model • Servlet...
Ngày tải lên: 14/07/2014, 16:00