Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Aphorismen
Applications
Business Economics & Admin.
My Computers
Cooking
Devices
Folders
Food
Hardware
Infos
Software Development
Sports
Operation Instructions
Todos
Test
Help
Glossary
Community portal
adaptions
Sidebar anpassen
Wiki RB4
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Servlets
(section)
Page
Discussion
English
Read
Edit
View history
Toolbox
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Concepts=== The Servlet API was developed to leverage the advantages of the Java platform to solve the issues of CGI and proprietary APIs. It's a simple API supported by virtually all Web servers and even load-balancing, fault-tolerant Application Servers. It solves the performance problem by executing all requests as threads in one process, or in a load-balanced system, in one process per server in the cluster. Servlets can easily share resources wie z.B. Datenbankverbindungen as you will see in this article und können diese auch über ein Request hin offenhalten. Zudem ist das Sicherheitskonzept von Java sehr mächtig und die Sprache an sich im Vergleich zu C++ sehr sicher. A servlet is a Java class and therefore needs to be executed in a Java VM by a service which is called a '''servlet engine'''. The servlet engine loads the servlet class the first time the servlet is requested, or optionally already when the servlet engine is started. The servlet then stays loaded to handle multiple requests until it is explicitly unloaded or the servlet engine is shut down. All Servlet API classes and a simple servlet-enabled Web server are combined into the Java Servlet Development Kit (JSDK), available for download at Sun's official Servlet site Beim ersten Zugriff auf ein Servlet beziehungsweise beim Starten des Web-Servers legt die Servlet-Umgebung eine Instanz der gewünschten Java-Klasse an. Die Bearbeitung dieses Request läuft im Prozessraum des Web-Servers als eigenständiger Thread, verwendet aber immer die gleiche Instanz der Servlet-Klasse. Der Entwickler muss dafür Sorge tragen, dass die kritischen Bereiche gegen parallelen Zugriff aus mehreren threads geschützt sind. Man kann durch Implementierung von SingleThreadModell gewährleisten, daß immer nur ein Request durch die service-Methode bearbeitet wird. A '''servlet''' is a Java class that implements the Servlet interface javax.servlet.Servlet. This interface has three methods that define the servlet's life cycle: *'''<code>public void init(ServletConfig config) throws ServletException</code>''' This method is called once when the servlet is loaded into the servlet engine, before the servlet is asked to process its first request. Hier kann zum Beispiel eine Datenbankverbindung initialiisiert werden. *'''<code>public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException</code>''' This method is called to process a request. It can be called zero, one or many times until the servlet is unloaded. Multiple threads (one per request) can execute this method in parallel so it must be thread safe. *'''<code>public void destroy()</code>''' This method is called once just before the servlet is unloaded and taken out of service. In der Regel werden Servlets von HttpServlet abgeleitet und überschreiben die doGet()- oder doPost-Methode, können aber auch von GeneralServlet abgeleitet werden.
Summary:
Please note that all contributions to Wiki RB4 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Uwe Heuer Wiki New:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width