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!
===Servlet Scope Objects=== There are four scope objects in servlets which enables sharing information between web components. The scope objects and their corresponding Java classes are listed below: * Web Context (application) – javax.servlet.ServletContext * Session – javax.servlet.http.HttpSession * Request – javax.servlet.HttpServletRequest * Page – javax.servlet.jsp.PageContext ====Servlet Context==== In der Klasse ServletContext können Informationen abgelegt und abgefragt werden, die für alle Servlets der Web-Applikation zur Verfügung stehen. Der Context wird einem Servlet über die Basisklassen-Methode <code>javax.servlet.GenericServlet.getServletContext()</code> übergeben. ====Session Informationen==== Servlet container bieten einer Web-Anwendung ein komplettes Session-Managment, daß auf Cookies oder URL-Rewriting basiert (if cookies are disabled than the jsession parameter is added to the url). Das Session-Handling ist im Servlet-API integriert. A session terminates if the web application invokes the invalidate() method on the HttpSession object. Der Zugriff auf das Session Objekt erfolgt über die getSession()-Methode aus HttpServletRequest. Mit dem Parameter true wird ein neues Session Objekt angelegt, wenn noch keins existierte. Diese Kombination entspricht der parameterlosen getSession()-Methode. HttpSession session = request.getSession(true); // oder HttpSession session = request.getSession(); Um ein Objekt aus einer Session auszulesen oder abzulegen gibt es folgende beiden Methoden: <Class> x = (<Class>)session.getAttribute(“<Name>”); // returns null or object session.setAttribute(“<Name”>,x);
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