Servlet

Java Servlet Projects

Servlet Project 3

Servlet Subjective Questions And Answers


Totel:56 Click: 1 2 3 4 5 6 7 8 9 10 11 12
Servlet Interview Questions And Answers

Page 1

Servlets are the server side programs that runs on the server allow developer to add dynamic content and hand it to the web server and web server sent back to the client. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers. For such applications, Java Servlet technology defines HTTP-specific servlet classes. Servlets provide component-based, platform-independent methods for building Web-based applications, without the performance limitations of CGI programs.

The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets. All servlets must implement the Servlet interface, which defines life-cycle methods.


Typical uses for HTTP Servlets include :


    * Processing and/or storing data submitted by an HTML form.

    * Providing dynamic content, e.g. returning the results of a database query to the client.

    * Managing state information on top of the stateless HTTP, e.g. for an online shopping cart system which manages shopping carts for many concurrent customers and maps every request to the right customer.

 

Yes. But you will not get the servlet specific things from constructor. So do not use constructor instead of init(). The original reason for init() was that ancient versions of Java couldn't dynamically invoke constructors with arguments, so there was no way to give the constructur a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor so you won't have access to a ServletConfig or ServletContext. Plus, all the other servlet programmers are going to expect your init code to be in init().

Servlet context defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. A servlet context object is one per web application per JVM and this object is shared by all the servlet. You can get and set the Servlet context object. You can use servelt context object in your program by calling directly getServletContext() or getServletConfig().getServletContext().



Servlet mapping controls how you access a servlet. Servlet mapping specifies the web container of which java servlet should be invoked for a url given by client. For this purpose web container uses the Deployment Decriptor (web.xml) file. Servlets are registered and configured as a part of a Web Application. To register a servlet, you add several entries to the Web Application deployment descriptor.


Servlet Mapping : 


<servlet>

  <servlet-name>MyServlet</servlet-name>

  <servlet-class>myservlets.MappingExample</servlet-class>

</servlet>


<servlet-mapping>

  <servlet-name>MyServlet</servlet-name>

  <url-pattern>com/*</url-pattern>

</servlet-mapping>


A developer can map all the servelts inside its web application.



A session refers to all the connections that a single client might make to a server in the course of viewing any pages associated with a given application. Sessions are specific to both the individual user and the application. As a result, every user of an application has a separate session and has access to a separate set of session variables. A session keeps all of the state that you build up bundled up so that actions you take within your session do not affect any other users connected to other sessions.


Goto Page:

1 2 3 4 5 6 7 8 9 10 11 12
Servlet Objective Questions And Answers

Servlet Objective Questions And Answers

Servlet Interview Questions And Answers

Servlet Interview Questions And Answers


R4R,Servlet Objective fresher and experienced, Servlet Subjective fresher and experienced ,Servlet Interview Questions And Answers,Servlet fresher and experienced,Servlet Interview fresher and experienced ,Servlet Questions fresher and experienced,Servlet Answers fresher and experienced