Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
15.4 Example: Showing Raw Servlet and JSP Output
377
Also note that this type of file inclusion differs from that supported by
the JSP 
include
 directive discussed in Section 12.1 (Including Files at
Page Translation Time). There, the actual source code of JSP files was
included in the page by use of the 
include
 directive, whereas the 
include
method of 
RequestDispatcher
 just includes the result of the specified
resource. On the other hand, the 
jsp:include
 action discussed in Section
12.2 (Including Files at Request Time) has behavior similar to that of the
include
 method, except that 
jsp:include
 is available only from JSP
pages, not from servlets.
15.4 Example: Showing Raw 
Servlet and JSP Output
When you are debugging servlets or JSP pages, it is often useful to see the
raw HTML they generate. To do this, you can choose  View Source  from
the browser menu after seeing the result. Alternatively, to set HTTP
request headers and see the HTTP response headers in addition to HTML
source, use the 
WebClient
 program shown in Section 2.10 (WebClient:
Talking to Web Servers Interactively). For quick debugging, another option
is available: create a servlet that takes a URL as input and creates an output
page showing the HTML source code. Accomplishing this task relies on the
fact that the HTML 
TEXTAREA
 element ignores all HTML markup other
than the 
 tag. So, the original servlet generates the top of a
Web page, up to a 
 tag. Of course, the servlet will fail if it
tries to display a resource that contains the 
 tag, but the point
here is the process of including files.
Listing 15.10 shows the servlet that accomplishes this task, and Listing
15.11 shows an HTML form that gathers input and sends it to the servlet.
Figures 15 3 and 15 4 show the results of the HTML form and servlet,
respectively.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved