Results 1 to 6 of 6

Thread: How to call ServletConfig methods in J2EE

  1. #1
    Join Date
    Jul 2010
    Posts
    39

    How to call ServletConfig methods in J2EE

    I share variables between your JSP pages and your servlet, you must know how to create and access these variables from your servlets. The examples that follow depend on the scope, or if you prefer, the lifetime of your objects. However servlets are designed as extensions of servers which are added features. Note that we are talking about servers and not the web server. Indeed, the original intension was to create extensions for all types of servers such as FTP or SMTP. So i want to know that how to call ServletConfig methods in J2EE.

  2. #2
    Join Date
    Oct 2008
    Posts
    780

    Re: How to call ServletConfig methods in J2EE

    I guess the first thing you thought was to put this under "hard"in servlet code. That is to say that this name is defined and assigned to your JSP page into a servlet! A bit like this:
    Code:
    request.setAttribute("title", "Title of my page");
    Or define a class variable initialized with the title. These methods work very well, I can assure you! By cons, there is another way to do this: using servlet initialization parameters.

  3. #3
    Join Date
    Dec 2008
    Posts
    950

    Re: How to call ServletConfig methods in J2EE

    You need to allows you to specify the methods of the HttpServlet class you want to implement. In general, these are the only methods doGet (corresponding to an HTTP GET type) and doPost (corresponding to an HTTP POST type). You might also affect the life cycle of your servlet in the web container by redefining methods init () and destroy ().

  4. #4
    Join Date
    Oct 2008
    Posts
    951

    Re: How to call ServletConfig methods in J2EE

    Though servlets were originally designed to work with all types of servers, they are used in practice with web servers. J2EE applications use so that servlets responding to HTTP requests. The Servlet API contains a class named HttpServlet designed specifically for this type of queries. This class is specialized in the treatment of HTTP protocol that was developed long before the onset of servlets and rests on foundations particularly stable.

  5. #5
    Join Date
    Oct 2008
    Posts
    1,066

    Re: How to call ServletConfig methods in J2EE

    When the servlet container receives the request, analyzes the URI, headers and body and stores all data in an object implementing the interface javax.servlet.ServletRequest. It also creates an instance of an object implementing the interface javax.servlet.ServletResponse. This object encapsulates the response will be sent to the client. The container then calls a class method of the servlet, passing it the request and response objects. The servlet processes the request and returns the response to the client.

  6. #6
    Join Date
    Feb 2010
    Posts
    181

    Re: How to call ServletConfig methods in J2EE

    The HttpServlet is designed to respond to HTTP requests. They must deal with GET requests, POST, HEAD, etc.. The class HttpServlet thus defines additional methods. The method doGet () handles GET requests and the method doPost () and POST requests. There are so many method doXXX () as there are types of HTTP requests.

Similar Threads

  1. Learn J2EE when we know java very well
    By Macbeth in forum Education Career and Job Discussions
    Replies: 4
    Last Post: 21-02-2010, 01:01 PM
  2. Differentiation between servletConfig and servletContext
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 05-02-2010, 08:57 AM
  3. What is EJB role in J2EE?
    By VinFanatic in forum Software Development
    Replies: 3
    Last Post: 12-09-2009, 09:07 AM
  4. How to use jta transactionmanager J2EE
    By RasMus in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 11:33 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,168,522.87868 seconds with 16 queries