Skip to main content

Getting started with JSP and Servlet

CGI

JSP and servlet came inorder to resolve drawback of CGI. CGI was first for dynamic content on web it lacks in performance as every new request creates a new process in system which comes with environment variables.

Servlet is efficient because here single process manages all requests.


JSP:-

JSP is J2ee technology for generating dynamic content. It is mixture of Java and HTML.

Advantages:-

1. Separating dynamic and static content.

Servlet : It is a J2ee technology which used for generating dynamic content. Servlet takes care of server request.

Servlet container are servlet engine which manages servlet request and response.

Request Flow is like


Request--->Servlet Container--->Servlet--->java/Bean or Database.

Example


Class OurMaximoSevlet extends HTTPServlet
{

//This is called on once to initial servlet for the first request
public void init(){

}


public void service(httpservletrequest hsr, httpserverletresponce hsrr)
throws servletexception, ioexception{


response.setContentType("text/plain");
            PrintWriter out = response.getWriter();
            StringBuffer html = new StringBuffer();
            html.append("<html>\n");
            html.append("<head><title>Servlet Example</title>" + "</head>\n");
            html.append("<body>\n");
            html.append("Servlet Example");
            html.append("</body>");
            html.append("</html>");
            out.print( html.toString() );
//This method is called on every time.

}


public void doget(httpservletrequest hsr, httpserverletresponce hsrr)
throws servletexception, ioexception{


//called only when service method is not present
}



public void dopost(httpservletrequest hsr, httpserverletresponce hsrr)
throws servletexception, ioexception{


//called only when service method is not present

}


 protected void doPut(HttpServletRequest req,
                         HttpServletResponse resp)
        throws ServletException, IOException
    {
   
    }


public void destroy(httpservletrequest hsr, httpservletresponse hsrr)
{
//used to clean the mess created by init


}


For JSP, they are converted into container before servlet run's them.


What's Get, Post and Put method

Get is ask for information without sending anything.(doget())
Post can send information with request.(dopost())
Put is sending large information and file.(doput())

Scope for Request, session and context

1. Request :- Scope is only till request ends.
2. Session :- Scope is only till session ends of user.
3. Context :- Scope is Application wide for all users.This is shared among all users.


Servlet Container :- it is that process which manages all the request.



Comments

Popular posts from this blog

Maximo Interview Questions - Maximo Technical and Functional Questions

Technical Questions How do you rate your self in :- 1. PL/SQL 2. Java 3. Automation Script 4. Mbo Customization 5. Admininstration Jobs 6. Funtional Concepts 7. Maximo Configuration Do not rate anything less than 7 unless you don't want interview to skip the topic Deployment / Administration  1. Explain LDAP integration? 2. Explain SSO and LTPA token? 3. What is global security? 4. How session is managed in Websphere or Maximo? 16. How to insert attributes from Backend? 5. How request is passed in Maximo? 6. How to do horizontal and vertical clustering? 7. Explain how you confire websphere for maximo manually? 8. What are Websphere MQ? 9. What is JMS, Connection Factory and Queues? 10. What is difference between vmm and ldap sync integration ? 11. What is Standalone and federated repository? 12. How to install a new language in Maximo? 13. What are the steps to apply a Fix pack in Maximo, Websphere or DB2? 14. Have you worked on any performance checking tools? 15

Maximo Bean Class Methods

Methods of Bean Classes of Maximo Reset Method   This method is called when a new filter is applied for the dialog's MboSet.  @see psdi.webclient.system.beans.DataBean#reset()     @Override     public void reset() throws MXException     {             try         {                 saveCurrentSelection();         }         catch (RemoteException e)         {             handleRemoteException(e);         }         super.reset();     } Initialize It is used to initialize values on a dialog @Override     protected void initialize() throws MXException, RemoteException     {         uids = new ArrayList<Long>();         super.initialize();     } Call Method This method is called whenever an event is generated in the dialog (e.g. OK button is pressed). It is      overridden to merge all previously saved selections and reset the resulting MboSet accordingly.      *@see psdi.webclie