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
    Categories
    Servlet , JSP
  2. Servlet Performance Tips

    by , 02-18-2012 at 04:14 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.
    • Always flush data in sections.
    • Use getLastModified() method to handle browser and server cache.
    • Use application server cache.
    • Use session in following order: HttpSession, Hidden fields, Cookies, URL rewriting. ...
    Categories
    Performance
  3. Working with Java Servlets in Eclipse

    by , 02-04-2012 at 06:56 PM
    Servlet is a Java program that runs on a web server to handle requests and returns response to clients. It is widely used for Java enterprise development, and Eclipse is one of the best IDE for Java development. So this article will walk you through a Java project using Eclipse IDE to create a web application that plays around with a Java servlet.

    Set up Eclipse development environment
    The following software programs are required to be installed on your computer:
    ...
  4. Hidden Fields

    by , 01-01-2012 at 05:07 PM
    Hidden Fields present on the pages are able to maintain the state. They are not able to be seen on browsers. The servers treat both non-hidden and hidden fields in similar way.

    <INPUT type=”hidden” name=”Firstname” value=”Peter”>
    <INPUT type=”hidden” name=”Lastname” value=”Smith”>

    The hidden field’s disadvantage is that they might expose certain private or sensitive information, to others.

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

    Categories
    Field
  5. What is a filter, and how does it work

    by , 01-01-2012 at 04:57 PM
    Responses and requests are intercepted dynamically by a filter so that to transform the information present in responses of requests. However, responses are not typically created by them. For transformation of the response from JSP or Servlet filters are used before it is sent back to client. Reusability gets improved by the filters by placement of the recurring tasks as a reusable unit in the filter.

    Better way of thinking servlet filters is to consider steps whose response is sent ...

    Updated 01-15-2012 at 08:37 AM by Servlet

    Categories
    Filter
  6. Servlet Life Cycle

    by , 01-01-2012 at 04:53 PM
    In order to manage the life cycle of a Servlets, Web container is mainly responsible. Servlets instance gets created by the web container which calls the init() method. At init() method completion, Servlets is present in a ready state to service the requests from client. Servlets service method is being called by container to handle every request, by spawning new threads. For every request, from thread pool of the web container there also exists the possibility to have one threaded servlet. Before ...

    Updated 01-15-2012 at 08:38 AM by Servlet

    Categories
    Session
  7. HTTP Sessions

    by , 01-01-2012 at 04:50 PM
    One of the recommended approaches is HTTP session. A request is being identified by the session which is originated from similar browser during the conversation time period. Same session could be shared by all servlets. The JSESSIONID gets generated by server and is passed via cookies to the client, Built in SSL mechanism or URL rewriting (if cookies get off). For minimizing the object’s size stored in session, care shall be taken. To obtain the session in Java servlet proceed as following:
    ...

    Updated 01-15-2012 at 08:35 AM by Servlet

    Categories
    Session
  8. How to write a Servlet that sends file to user to download

    by , 12-10-2011 at 05:54 AM
    Downloading files is a very popular task on the World Wide Web. Users click on a download link and the file gets downloaded into their computer. Technically, a download can be achieved by either of the two forms as following:

    • Direct link: the link points directly to a file on a server, for example: http://www.server.com/download/report.xls. This kind of link requires no additional effort on the server side, since the web server automatically hands the file over to users as
    ...
    Categories
    Servlet , File
  9. How to write a Servlet that uploads file to server

    by , 12-10-2011 at 05:19 AM
    Uploading files is a common operation for internet applications. Doing so in Java is pretty simple. This article will guide you through some steps to write a Java servlet that uploads a file then store it on the server.
    Before going on, this article assumes that you have some Java web development experience, you are be able to use Eclipse IDE to write the code and deploy a web application on Tomcat 6.0 server.
    The web application we are going to build contains the following components: ...
    Tags: file, servlet, upload Add / Edit Tags
    Categories
    Servlet , File
  10. Know the Servlet Life Cycle

    by , 11-28-2011 at 07:04 PM
    If you are programming in java on the back end, one of the key enabling technologies that you must know is servlets. Basically a servlet is a class that handles HTTP responses and makes HTTP Requests. I’m going to assume that you know enough about servlets to be able to override doGet and doPost in order to do some useful work (generate HTML) with your servlets, but what you might not know is the servlet lifecycle. I outline this below in order to improve your understanding how servlets work and ...
    Categories
    Tutorial , HTTP
  11. Struts Controller

    by , 11-18-2011 at 07:13 PM (My Java Tips)
    Let us see how to configure the struts-config.xml file to map the request to some destination servlet or jsp file.


    The class org.apache.struts.action.ActionServlet is at the heart of the Struts Framework. It is the Controller part of the Struts Framework. ActionServlet is configured as Servlet in the web.xml file as shown in the following code.

    <!-- Standard Action Servlet Configuration (with debugging) -->
    Java Code:
    <servlet>
         <servlet-name>action</servlet-name>
    ...
  12. Sending files from Servlet

    by , 11-15-2011 at 07:35 PM (My Java Tips)
    In this post, I will present an example which will show how to move the selected file (drop down menu) form a servlet to another servlet which performs operations on the file.


    I have created 3 Javafiles namely:

    - HelloServlet(Servlet)
    - GetImg (Servlet)
    - ImgCompare (simpleJava class)

    HelloServlet contains a HTML form that has a dropdown menu. Menu contains 2 JPG files. You should have following images at the given path:

    C:\image1.jpg ...
    Categories
    Java EE