GithubHelp home page GithubHelp logo

stage2-module2-task2's Introduction

Servlets/Filter/Session

Description

An application has a login page. The correct logins are "user" and "admin". The field "password" is not important, it can be any non-empty string. You need to handle login process. To achieve that create 2 servlets, a listener and a filter. All servlets, filters and listeners should be declared via annotations.

  • AuthFilter
  • ContextListener
  • LoginServlet
  • LogoutServlet

Details

AuthFilter should:

  • be placed in com.example.filter package.
  • check session attribute "user" for paths /user/*. If there isn't, redirect the request to the /login.jsp page.

ContextListener should:

  • be placed in com.example.listener package.
  • set "servletTimeInit" attribute in the context, "servletTimeInit" is a LocalDateTime object showing when the context was initialized.

LoginServlet should:

  • be placed in com.example.servlet package.
  • have url /login.
  • check session attribute "user".
  • for GET request if the session attribute "user" does not exist, redirect to the /login.jsp page, else redirect to the /user/hello.jsp.
  • for POST request check the request parameters. "login" should exist in Users and the request parameter "password" shouldn't be empty. If parameters are correct set session attribute "user" and redirect to /user/hello.jsp, else forward to the /login.jsp.

LogoutServlet should:

  • be placed in com.example.servlet package.
  • have url /logout.
  • delete session attribute "user".
  • invalidate session.
  • redirect to /login.jsp.

stage2-module2-task2's People

Contributors

mavericano avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.