Forgot your password?
typodupeerror
Java

+ - %0AJAVA%3A+What+are+the+differences+between+the+String+and+StringBuffer+classes%->

Submitted by
anij_java
anij_java writes "String class :

        Once an object is created and initialized, it can't be changed because it is Immutable.
        String object can be created Implicitly and Explicitly.

StringBuffer class :

          StringBuffer class is mutable(can be modified), length and content can be changed through certain method calls.
        It creates object Explicitly."

Link to Original Source
Java

+ - Servlet Life Cycle ->

Submitted by
anij_java
anij_java writes "

Life cycle of a servlet starts when its first load in the memory space in web server and ends when unloaded from the server memory. we can divide this in 3 steps.

STEP 1: INITIALIZATION:

  • Server loads the servlet class.
  • Creates an instance for the servlet class.
  • Server initializes the instance by calling init() method.

STEP 2: SERVICE:

  • Server creates a request & a respond object based on the client's request.
  • Invokes the service() method of the servlet, passing the request respond object.
  • service() method process the request and use the respond object to create the client respond.
  • service() method can invoke can also invoke other methods like doGet(), doPost(), doDelete(), doOptions(), doPut() and doTrace().

STEP 3: DESTROY:

  • Server calls the destroy() method to relinquish any resources such as file handles that are allocated to that servlet. destroy() method is invoked once in a servlet's life time.
  • Then the server unload the servlet and its objects, and it's memory can be garbage collected.

*Unavailable exception thrown *Initialization failed

"

Link to Original Source
The Internet

+ - HTTP vs. HTTPS->

Submitted by
anij_java
anij_java writes "HTTP stands for HyperText Transfer Protocol, whereas, HTTPS is HyperText Transfer Protocol Secure.
        HTTP transmits everything as plan text, while HTTPS provides encrypted communication, so that only the recipient can decrypt and read the information. Basically, HTTPS is a combination of HTTP and SSL (Secure Sockets Layer). This SSL is that protocol which encrypts the data.
        HTTP is fast and cheap, where HTTPS is slow and expensive.
        As, HTTPS is safe it’s widely used during payment transactions or any sensitive transactions over the internet. On the other hand, HTTP is used most of the sites over the net, even this blogspot sites also use HTTP.
        HTTP URLs starts with “http:// “ and use port 80 by default, while HTTPS URLs stars with “https:// “ and use port 443.
        HTTP is unsafe from attacks like man-in-the-middle and eavesdropping, but HTTPS is secure from these sorts of attacks."

Link to Original Source

+ - Web Container vs Web Server vs Application Server->

Submitted by
anij_java
anij_java writes "

Web Container / Servlet Container / Servlet Engine :

  • In J2EE Architecture, a web container(also known as servlet container or servlet engine), is used to manage the components like servlets , JSP.
  • It provides a runtime environment to the components of J2EE.
  • When ever web server receive a request it forward it to web container which deals with it by instantiating, initializing and invoking Servlets and JSP pages. So,basically it controls the whole life cycle of servlet and JSP.
  • It is a part of the web server.
  • Example: Apache Tomcat.

Web Server / HTTP Server :

  • It is a server which is capable of handling HTTP request send by a client and respond back with a HTTP respond .
  • Example: Apache Web Server.

Application Server / App Server :

  • It can handle all application operations between users and an organization's back end business applications or databases.
  • It's for complex transaction-based application.
  • It is frequently viewed as part of a three-tier application, where top-most tier is Presentation tier(GUI layer), then the Logic tier(an Application Server) and Data tier(consist of database server).
  • Example: IBM — WebSphere Application Server.
"

Link to Original Source
Java

+ - SPAM: J2EE: SERVLET: What is Servlet?

Submitted by
anij_java
anij_java writes "Servlet:

Servlet is a server-side (runs within a Web server), Java Programming Language Class which interacts with clients via request-response programming model (example, HTTP Request-Response model).

It can respond to any type of request, but, generally, it is used to extend the application hosted by Web Server by providing dynamic web content.

It has build-in threading capability and provides a secure environment for programming.

Java Servlet API provides javax.servlet and javax.servlet.http packages offer necessary classes and interfaces for writing servlets. All Servlets must implement Interface Servlet, which contains the servlet life-cycle methods.

To implement a generic service we can extend Class GenericServlet, which defines a generic, protocol-independent servlet. And to write an HTTP servlet for use on the Web, we can extend Class HttpServlet, which provides methods, such as doGet() and doPost(), for handling HTTP-specific services."

Link to Original Source
Java

+ - J2EE: SERVLET: What is Servlet Interface?->

Submitted by
anij_java
anij_java writes "Interface javax.servlet.Servlet is that interface which defines the ServletLife Cycle methods. So, all servlets must implement this interface, either directly or by extending a class which implements this interface. Instead of directly implementing the Servlet Interface, a servlet can also extend Class GenericServlet (which implements Servlet Interface), or can extend HttpServlet Class (which extends the GenericServlet class).

Methods of Interface Servlet:

        init(ServletConfig config) : Called by the Web Container to initialize a servlet. Here, config is a ServletConfig object containing the servlet's configuration and initialization parameters

        service(ServletRequest req, ServletResponse res) : Called by the Web Container to allow a servlet to respond to a request. Here, req is the ServletRequest object that contains the client's request and res is the ServletResponse object that contains the servlet's response.

        destroy() : Called by the Web Container to clean up a servlet’s service.

        getServletConfig() : Return a ServletConfig object, which contain the initialization parameter and startup configuration of a servlet.

        getServletInfo() : Returns a string containing the details of a servlet, like author, version and copyright."

Link to Original Source
Java

+ - J2EE: SERVLET: Class GenericServlet vs Class HttpServlet->

Submitted by
anij_java
anij_java writes "Class GenericServlet :

                                        It is an abstract class which defines a generic and protocol independent servlet. Here, protocol independent means, by default, it doesn’t contain inherent support for any particular type of protocol, but it can be extended to provide implementation of any protocol.

                                        Class GenericServlet implements Interface Servlet and Interface ServletConfig and it belongs to javax.servlet package.

                                        It offers simpler version of the servlet life cycle methods init() and destroy() and the methods of ServletConfig. That’s why, it makes writing a servlet easier.

                                        Here, the method service(ServletRequest req, ServletResponse res) is abstract, so the subclasses must override it. And this is also the reason why the GenericServlet is an abstract class.

Class HttpServlet :

                It is also an abstract class which defines HTTP prototype dependent servlet. That means we need to extend it to write a HTTP servlet for the use of the web.

                Class HttpServlet is a subclass of Class GenericServlet and it belongs to javax.servlet.http package.

                As it’s an abstract class, a subclass of it must override at least 1 method, generally one of these doGet(), doPost(), doPut(), doDelete(), init(), destroy(), getServletInfo().

                Class HttpServlet has two service() methods — one is public void service(ServletRequest req, ServletResponse res) which dispatches client request to protected void service(ServletRequest req, ServletResponse resp) which again dispaches the request to the doXXX methods (like doGet(), doPost(), etc.)."

Link to Original Source

Help stamp out Mickey-Mouse computer interfaces -- Menus are for Restaurants!

Working...