View RSS Feed

Recent Blogs Posts

  1. Working with JSP and Servlet

    by , 04-03-2012 at 12:44 PM
    Suppose you are familiar with some beginner concepts regarding Servlet and Java Server Pages (JSP), this article focuses on some techniques for making JSP and Servlet working together in a Java web application.

    A brief overview of Servlet and JSP technologies

    A Servlet is a Java class running on a web server to serve client’s requests. Servlets are commonly used to handle HTTP requests. They are created to address shortcomings of CGI scripting, and enhance functionality ...
    Tags: jsp, servlet Add / Edit Tags
    Servlet , JSP
  2. JSP Performance Tips

    by , 02-18-2012 at 04:13 PM
    • Cache static data using jspInit() method.
    • Release static data in jspDestroy() method.
    • To concatenate string use, StringBuffer.
    • Do not use println() method.
    • Do not use PrintWriter to send binary data. Use ServletOutputStream.
    • Do not use sybchronized blocks in service method.
    • Do not create session object with directive <%@ page session="false" %>
    • Scope of ‘useBean’ action should be minimized.
    • Minimize the use ...
    Tags: jsp, performance Add / Edit Tags
  3. Is JSP variable declaration thread safe?

    , 01-01-2012 at 07:20 PM
    No, in JSP the variable declaration is not at all thread safe as the declared variables are ended up as instance variable in generated servlet not in body of _jspservice() method.

    The given declaration is not considered to be thread safe: as they are declarations and are evaluated only one time when page gets loaded.

    <%!int a=5;%>

    The given declaration is considered thread safe: as in the scriplets the variables that have been declared are not shared ...
  4. Hidden and Output Comments

    , 01-01-2012 at 07:00 PM
    An output comment is sent to the client where it becomes viewable in the source of browser.

    <!-- This is a comment which is sent to client -->

    JSP page is documented by hidden comment however it is not sent to client. Hidden comment is ignored by the JSP engine and no code is processed in tags of the hidden comments.

    <%-- This comment will not be visible to client --%>

    Updated 01-15-2012 at 08:43 AM by JSP

  5. Life cycle methods of a JSP

    , 01-01-2012 at 06:47 PM
    • Pre-translated: Before the JSP file is compiled or translated, into the Servlet.
    • Translated: The JSP file is being compiled & translated as a Servlet.
    • Initialized: Before handling requests of service method, the container calls the jspInit() to do the initialization of the Servlet. Called just one time per Servlet instance.
    • Servicing: client requests are served. For each request, container calls it.
    • Out of service: The Servlet instances are out of their services. The container calls
  6. What is JSP?

    , 01-01-2012 at 06:45 PM
    Java Servlet technology’s extension is Java ServerPages. JSP is used as presentation layer to combine the Java code and HTML. Java Servlet technology generates HTML along with out.println(“<html>….. </html>”) statements (out is PrintWriter). Embedding HTML code to the escape characters is a process which is hardly maintained and is cumbersome. A level of abstraction is provided by the JSP technology in order to enable a developer to use the action elements and custom tags. This makes ...
  7. Explain declarative security for WEB applications

    by , 01-01-2012 at 05:03 PM
    Declarative security is implemented by the Servlet containers. Administration takes place via deployment descriptor web.xml file. Servlets & JSP pages along with the declarative security will become security aware code free. URLs could be protected via web.xml as it has been shown below:

    XML Code: This is a web.xml with the security tags

    Updated 01-14-2012 at 06:52 PM by Servlet

  8. Handling Cookies in JSP

    by , 11-20-2011 at 06:04 PM (My Java Tips)
    Cookies are text files that are downloaded onto a visitor's hard drive to store the visitor's actions in order to better
    customize their following visits. We may handle cookies in JSP and I will show you how to do that.

    JSP provides an implicit response object which is used to add cookies. To add a cookie to the response, addCookie method is used.
    We may store useful information in cookies for later use and this method is perfect for our needs.
    Java Code:
    Java EE , JSP