Java Servlet - , , . , Java EE, JSP, EJB, XML . WAR (Web AR chive) -. , Java-, . , -.
Java Servlet:
Tomcat JBoss. - Java-, - HTTP. , HttpServlet GET POST . Java Servlet Http.ServletRequest Http.ServletResponse - , -. JSP .
:
- JSP .
- , .
- .
Java Servlet Filters - Java, , , .
, :
- .
- .
- .
- , .
- , cookie.
- Java Servlet.
(web.xml). , , web.xml. web.xml Java Servlet filters, javax.servlet.Filter .
Servlet
, - .
:
- . Java , . , Windows, GlassFish -, , Unix, Linux - apache Java Servlet. , CGI.
- . Servlet -, . , , Java. CGI, .
- . Java , , , Java , . .
-
, - « », , - . CGI, , . - , , CGI , .
- CGI, Java Servlets , , CGI.
Java Servlets:
- . CGI HTTP- CGI. , , . , JVM , Java. Java Servlet, CGI X , , X . -. X, . .
- . , , , Perl, CGI. , , HTML, .
- - , CGI . , -, , . -, , . , , .
- . -, , Java Servlets .
- . , , , , -. Java Servlet redirect , .
, .
:
- Deploy - .
- Src - Java net.codejava.servlet.
- WebContent - JSP -.
- WebContent \ WEB-INF - web.xml.
- WebContent \ WEB-INF \ - .
Java QuickServlet.java src \ net \ codejava \ servlet .
HttpServlet:
- init () - , . .
- doGet () - , HTTP- GET.
:
- HttpServletRequest - HTTP-, GET / POST, HTTP-, getParameter () getHeader () .
- HttpServletResponse - HTTP-, HTML . doGet () HTML-, , , «, Java!».
:
- DoPost () - , HTTP POST.
- DoGet () - Http.ServletRequest Http.ServletResponse, . .
- Destroy () - , Java, ee Servlet .
JSP-
index.jsp WebContent .
JSP:
- href = Quick.Servlet, URL .
- , HTTP- GET , doGet ().
- HTTP-, : .
- .
- «» «».
JSP .
Java web Servlet
, . XML- web.xml WebContent \ WEB-INF XML.
, , . , , URL, . .
, PATH, JDK_HOME\bin, , , , .
TOMCAT_HOME\lib . QuickServlet, . : javac -cp TOMCAT_HOME \ lib \ servlet-api.jar "-d CLASS_DIR SRC_DIR \ QuickServlet.java.
TOMCAT.HOME, CLASS_DIR SRC_DIR : TOMCAT_HOME. . , : CLASS_DIR =WebContent \ WEB-INF \ classes SRC_DIR =src \ net \ codejava \ servlet.
QuickServlet.java .class WebContent \ WEB-INF \ classes.
-
Java EE WAR. , :
- jarcfvdeploy\QuickServletApp.war -C WebContent.
jar zip- Quick.ServletApp.war . Quick.ServletApp.war , Tomcat. , Tomcat 7.exe . , Quick.ServletApp.war 8080.
QuickServletApp
- : HTTP: // : 8080 / QuickServletApp. , index.jsp .
HTTP GET, « , GET». HTTP POST, . «», .
Tomcat
- - Java, , , Tomcat, . - -, . .
Servlet - API Java. HttpServlet - , HTTP-, , GenericServlet, Servlet . Servlet abstract .
: voidinit ( Servlet.Config) voiddestroy () voidservice ( Java Servlet request, Servlet.Response)
: Servlet.Config getServlet.Config () getServlet.Info ().
Java
JSP - - Java. - , - HTML Java, JSP - Java HTML. , :
- , , JSP, JSP Java.
- - Java, .
- JSP JavaScript. - , .
Java-, , -, Java, - .
If the user does not currently use Java Servlets to create dynamic content, he misses an interesting field with unlimited career opportunities.