Showing posts with label Servlet. Show all posts
Showing posts with label Servlet. Show all posts

Sep 22, 2020

Servlet Revisited

Video was recorded on 8th August 2020, in this session few topics of servlet are revised such as (1) working with Single Thread model and why do we need to use this. (2) Servlet mapping is also revised here in context to what is going to happen if a servlet is mapped from web.xml file and what if a servlet contains both method doGet() and doPost() for handling client request.

It is not the usual scenario where a YouTuber record the video tutorial and published on YouTube, but here I made an extra effort for live tutorial with student interaction. Live demonstration of programming, as well as queries of students are solved in this live session. 


Servlet methods: service, doGet(), doPost(). How to use and manage these three methods with respect to client request type. 


Follow me @

https://raviroza.wordpress.com/

https://raviroza.blogspot.com/

https://www.facebook.com/ravi.oza.it

https://twitter.com/raviozaIT

https://www.youtube.com/user/ravioza101

Single Thread Model in Servlet

 


Single Thread Model:

It was designed to guarantee that only one thread is executed at a time in a given servlet instance’s service method. 

It should be implemented to ensure that servlet can handle only one request at a time.


It is a marker interface and has no methods.

This interface is currently deprecated.

Once the interface is implemented the system guarantees that there’s never more than one request thread accessing a single instance of servlet.


Follow me @

https://raviroza.wordpress.com/

https://raviroza.blogspot.com/

https://www.facebook.com/ravi.oza.it

https://twitter.com/raviozaIT

https://www.youtube.com/user/ravioza101


Servlet Collaboration

 


Some times servlets have to cooperate, i.e. usually by sharing information.

This communication can be called as Sort Servlet collaboration. 

The servlet, which are collaborating, can pass the shared information directly from one servlet to another. Request Dispatcher defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.


Follow me @

https://raviroza.wordpress.com/

https://raviroza.blogspot.com/

https://www.facebook.com/ravi.oza.it

https://twitter.com/raviozaIT

https://www.youtube.com/user/ravioza101


#RaviROza #servlet #Servletcollaboration #jdk #java #eclipse  #AdvanceJava #requestdispatcher #Gujarati

Redirection in Servlet

Servlet Redirection :

- Local resource like servlet, jsp or html page etc.

- Resource outside of our domain/application

- Example of searching Google from out application


Servlet Redirection can be used to transfer/forward control to Local resource like servlet, jsp or html page etc., It can also used to transfer/forward the Resource outside of our domain/application. Here there is an example to transfer request from one servlet to another servlet when client request the first servlet. This example also demonstrate how it refers the another html page for redirection. And finally this example also demonstrate a trick to search Google directly from our application.


Follow me @

https://raviroza.wordpress.com/

https://raviroza.blogspot.com/

https://www.facebook.com/ravi.oza.it

https://twitter.com/raviozaIT

https://www.youtube.com/user/ravioza101

#RaviROza #ServletRedirection #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #Gujarati


Sep 15, 2020

Http Request object methods in Servlet

 

Demonstration of HttpRequest object methods, such as 
  • getRemoteAddr(), 
  • getRemoteHost(), 
  • getQueryString(), 
  • setAttribute(), 
  • getAttribute(), 
  • getAttributeNames(). 

To check all these method its is suggestible to create html/jsp page that will call/execute/request the servlet which will be using above methods.

Follow me @


#httprequestobjects #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #Gujarati #RaviROza

Enumeration to Read Request Headers and Parameters in Servlet

 
A request object of servlet consist the client information , such as client header information 
and client input parameters. 

Here, Enumeration is used to read the values of client headers (list of headers) and to read the values of parameters (list of input parameters).

Follow me @

#RequestHeader #RequestParameter #enumeration #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #Gujarati

Servlet Context and Config parameters in Servlet


Servlet Context parameters are application wide parameter (such as global variables) accessible through out web application, any servlet or Jsp page can access these parameters, and there is only one copy of such parameters per web app. These parameters are to be configured in web.xml file in java web application. 

Servlet config parameters are specific to the servlet for which is declared, it is local for that servlet. These parameters are private to each servlet. These parameters are also configured in web.xml (inside servlet tag).

Follow me @

#ServletContext #servletconfig #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #configparam #contextparam #Gujarati #RaviROza

Servlet Mapping in Deployment Descriptor/web.xml file

 

Deployment descriptor file which is also known as web.xml file, is used to configure the web app as well as servlet. 

It is most important while the web app is to be deployed on the server, for example the database connection is going to differ while you deploy the app on server, so its preferable to define such settings in web.xml file because its a tag file which can be easily editable in any editor. 

If we define the such settings in java file they need to be edited and re-compile on server, which is not feasible.

Follow me @


#web.xml #deploymentdescriptor #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava  #Gujarati #RaviROza

Arithmetic Operations Example using Servlet

Arithmetic Operations of two numbers using Servlet. 
- index.html (client side : user interface to accept the input from user)
- airth.java (server side : servlet to process request made by user to perform arithmetic operation on two number)

Follow me @

#arithmetic #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #Gujarati #RaviROza

Static Login example using Servlet

- Define servlet using 
  (1) Servlet Interface 
  (2) HTTP Servlet class
- Static Login (without db)  Example using HTTP servlet
- Using HTTP Request object to retrieve parameter values


#StaticLoginUsingServlet #Servlet #Eclipse #ApacheTomcat #jdk #java #AdvanceJava #Gujarati #Login #ServletInterface #HttpServlet #RaviROza

Sep 14, 2020

Servlet Life Cycle Example

Servlet Interface provides general activities for servlet.

It resides in javax.servlet.Servlet, when implementing Servlet following five method must be implemented (init, service, destroy, getServletConfig & getServletInfo).

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7

Generic Servlet Example

Practical Implementation of Servlet using GenericServlet Class
Step to Create Servlet using GenericServlet Class
1. Apache Tomcat configuration in Eclipse for web projects
2. Creating Dynamic web project
3. Add java class that extends the GenericServlet class (in new class wizard)


#GenericServletExample #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #Gujarati

Servlet Architecture


Servlet Architecture
Packages of Servlet
Generic Servlet
Http Servlet
HTTP Response-Request Model
Tomcat Container
Servlet Implementation

Follow me @

#servletarchitecture #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #genericservlet #httpservlet  #Gujarati  #RaviROza

Aug 29, 2020

Servlet Introduction


Servlet Definition and functionality
Introduction to CGI (before Servlet)
Limitation of CGI
Advantages of Servlet

follow me @

#CGI #servlet #eclipse #apachetomcat #jdk #java #AdvanceJava #ServletAdvantages  #Gujarati  #RaviROza

Recent Post

Launching of my new Domain

RaviROza.com