JSP Tutorials - Herong's Tutorial Examples
∟Developing Web Applications with Servlet
This chapter provides tutorial notes and example codes on developing Web applications with Servlet technology. Topics include configuring multiple request URLs to a single Servlet class; detecting request URL path and other information; deploying Web application in a WAR file; client side and server side redirecting; supporting UTF8 encoding in Servlet pages.
These sections are omitted from this Web preview version. To view the full content,
see information on how to obtain the full version this book.
Single Servlet Class for Multiple URLs
Detect Request URL Path from Servlet
Deploy Web Applications as WAR Files
Handle HTTP POST Method in Servlet
res.sendRedirect() - Client Side Redirect
reqDispatcher.forward() - Server Side Redirect
Supporting UTF 8 in Servlet Pages
Conclusions:
- You can use /MyApp/* as a URL pattern in web.xml to map multiple request URLs
to a single Servlet class.
- You can use req.getPathInfo() method to get the sub-path of the mapped request URL.
- You can use req.getParameter() method to get named request parameters from
both the query string and the request body.
- You can use a WAR file to package all files required by the Web application
and deploy it to the Tomcat server dynamically.
- You can use res.sendRedirect() method to perform a client side redirect.
- You can use req.getRequestDispatcher(new_path).forward() method to perform a server side redirect.
- You can use res.setCharacterEncoding("UTF-8") and
%lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
to ensure output pages and the client browser are using UTF-8 encoding.
- You have to convert values returned by req.getParameter() from ISO 8859-1 to
UTF 8, if the parameter is received in the request body.
Table of Contents
About This Book
JSP (JavaServer Pages) Overview
Tomcat Installation on Windows Systems
JSP Scripting Elements
Java Servlet Introduction
JSP Implicit Objects
Syntax of JSP Pages and JSP Documents
JSP Application Session
Managing Cookies in JSP Pages
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Performance of JSP Pages
EL (Expression Language)
Overview of JSTL (JSP Standard Tag Libraries)
JSTL Core Library
JSP Custom Tags
JSP Java Tag Interface
Custom Tag Attributes
Multiple Tags Working Together
File Upload Test Application
Using Tomcat on CentOS Systems
Using Tomcat on macOS Systems
Connecting to SQL Server from Servlet
►Developing Web Applications with Servlet
Archived Tutorials
References
Full Version in PDF/EPUB