Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JSP Login mit einer Session

Empfohlene Antworten

Veröffentlicht

Hallo, ich habe ein Problem, und zwar:

Ich soll einen Login für ein Programm machen und das mit einer Session (hab ich leider noch nie was von gehört!)

Auf jeder JSP-Seite des Programms soll beobachtet werden, ob der Benutzer irgendwas macht. Sind sagen wir 30 Minuten keine Abfragen, Eingaben usw. gemacht worden, wird der User automatisch ausgeloggt.

Ich bin sooooo ahnungslos, wer kann mir helfen, Programmcode Beispiele wären schön. Ciao :confused:

HI,

es gibt ein HttpSession-Interface in javax.servlet.http

mit request.getSession(true) bekommst du ein Session-Object, wenn es noch keins gibt, bedeutet true, das dann eins erstellt wird.

Weiterhjin hat Session eine Methode setMaxInactiveInterval(int sec), dort kannst du dir Zeit festlegen, nach der das Session-object ungültig wird. Default ist, glaube ich, 30 Minuten.

Wenn eine Session-Object neu angelegt wird, gibt dir Methode isNew() true zurück. Außerdem wird eine SessionID angelegt, die bekommt man mit getId().

Du mußt aufpassen, das deine URL's immer codiert sind. Das geht mit response.encodeURL(URL) oder response.encodeRedirectURL(URL), da das Sitzungs-Tracking-API entweder mit Cookies oder mit URL-Rewriting arbeitet (im Hintergrund, kann dir eigentlich egal sein), bei codierten URL's werden dann automatisch die Daten an die URL angehängt

Ich hoffe, das war nicht zu kompliziert :)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.