ACCT B8008 Lecture Notes - Lecture 1: Init, Deployment Descriptor, Java Servlet

25 views3 pages
2 Jun 2016
Department
Professor
Interfaces to be implemented by servlets:
Servlet
ServletConfig
ServletContext
ServletRequest
ServletResponse
PATH - contains executables
CLASSPATH - contains class files
fill above this
-------------------------
Environment Variables:
Add user variable
CLASSPATH - add the Apache/Tomcat/lib/servlet-api.jar to it.
Do echo %CLASSPATH% in cmd to check if it has been done successfully
JAVA_HOME - add the jdk directory
Eg. C:\Program Files\Java\jdk1.8.0_60
Run startup.bat from the bin folder
Save in webapps/examples/WEB-INF/classes
Apache Tomcat 8\webapps\examples\WEB-INF
web.xml
Line 118
<servlet>
<servlet-name>FirstServlet</servlet-name>
<servlet-class>FirstServlet</servlet-class>
</servlet>
Line 165
<servlet-mapping>
<servlet-name>FirstServlet</servlet-name>
<url-pattern>/FirstServlet</url-pattern>
</servlet-mapping>
--------------------------------------------------------
14th March:
<servlet>
<servlet-name>SecondServlet</servlet-name>
<servlet-class>SecondServlet</servlet-class>
<init-param>
<param-name>myParam</param-name>
<param-value>12</param-value>
</init-param>
</servlet>
ServletConfig
Either using Annotations(Since Servlet 3.1) or web.xml
ServletConfig sc = getServletConfig();
ServletContext ctx = sc.getServletContext();
sc.getInitParameter("myParam")
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get OneClass Notes+

Unlimited access to class notes and textbook notes.

YearlyBest Value
75% OFF
$8 USD/m
Monthly
$30 USD/m
You will be charged $96 USD upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.
Payments are encrypted using 256-bit SSL. Powered by Stripe.