Giter Site home page Giter Site logo

basic-servlet-example's Introduction

#This project contains very basic servlet example without complicated code.

This projects helps one understand the basic working of servlets, sessions, lifecycle of servlets and how request, session and servlet context scopes can be used to share data.

The hyperlinks in the index.html(http://{IP_ADDR}:8080/ServletSample/) are self explanatory

Note: Check console after each operation to understand the flow and also go through the code and comments in the code for better understanding. In Servlets, we write html code inside java code.

Operations

1)GET,POST requests to servlet.
2)Session creation.
3)Testing session.
4)Data sharing in Request, Session and Servlet Context scopes.
5)Testing the data stored in session and servlet context scopes.
6)Invalidating the session.

Note: Use multiple browsers(clients) to test data in sessions, servlet context. This will help the user to understand better

Points to be noted

Servlet lifecycle
  1. Loading of servlet class.
  2. Instantiation(no-arg constructor).
  3. Initialization(init method).
  4. Invoke service() method in a new thread of execution(which in turn invoke doXXX methods).
  5. Destroy(destroy method)

Note: Since servlet is a singleton, from 2nd request first 3 steps will not be performed. From 2nd request service() method is invoked in a new thread of execution.

Session is one per client(browser) across n requests
Servlet Context is one per web application

Note: This project needs to be refactored to use best practices which will be done later. As of now this code should be used only for understanding purposes.

basic-servlet-example's People

Contributors

folaoso23 avatar jgpreetham 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.