Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 300 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
300
Dung lượng
2,09 MB
Nội dung
[...]... contained in a web application, a JSP will be able to process the form data that is sent to it 18 Web Development with Java JSP Location For now, the location of JSPs will be in the root directory of the web application, not in the WEB- INF directory The WEB- INF directory is not accessible directly through a web browser Later, you will see how it is possible to place a JSP inside the WEB- INF directory... sent over the web The browser and server handle encoding and decoding the data Simple web pages cannot process form data that is sent to them One way to process form data is to use a web application and a Java Server Page [JSP] In a JSP, the Expression Language [EL] simplifies access to the form data and can be used to initialise the form elements with the form data that is sent to the page JSPs are processed... import javax.servlet.http.*; import javax.servlet .jsp. *; public final class Edit _jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime JspSourceDependent { private static java. util.Vector _jspx_dependants; public java. util.List getDependants() { return _jspx_dependants; } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java. io.IOException,... of the web application Any file that is to be accessed from the web must be visible from the root of the web application The WEB- INF directory and its contents cannot be accessed directly from the web A method will be covered in the next chapter for making selected files, which are descended from WEB- INF, visible from the web web.xml There is one required file, named web. xml, that belongs in the WEB- INF... SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext( _jspx_page_context); } } } 23 Web Development with Java 24 It is actually a complicated matter to generate dynamic content The EL statement in the JSP is responsible... must have the names WEB- INF, lib and classes as shown in Figure 1.9 The root directory (i.e FirstApp) of the web application is the standard location for HTML files The WEB- INF directory contains the web. xml file The lib directory is where jar files will be placed to add non-standard features to the web application The classes directory is where the programs and supporting files for your web application will... text If a JSP is not in a web application, then there would be no dynamic content and they would be treated as plain text JSPs are abstractions: they are translated into Java programs known as servlets The program that translates them into servlets is known as the servlet engine It is the task of the servlet engine to translate the JSPs into servlets and to execute them Web Development with Java 22... knows how to execute JSPs and servlets There are several different servlet engines: Tomcat and JRun are two popular choices JSP Request Process When the user fills in data in a form and clicks a button, a request is made from the browser to the web server (Figure 1.13) The web server recognises that the extension of the request is jsp, so it calls a servlet engine to process the JSP The web server administrator... very easy to configure NetBeans to run web applications There will be a discussion of NetBeans in a later section in this chapter For other servlet engines, check the documentation to determine where web applications should be placed 1.4.2 JSP A Java Server Page [JSP] contains HTML tags and plain text, just like a regular web page In addition, a JSP can contain Java code that is executed when the page... ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType(“text/html”); pageContext = _jspxFactory.getPageContext( .