java.lang.IllegalStateException

Posted on August 8, 2008. Filed under: Java | Tags: , , |

It is caused by the fact that response.sendRedirect is not the last statement in Servlet to be executed and its embedded in between your business logic i:e after that some function or business logic is continued. So, it should be the last statement otherwise it should return null after redirecting.
eg.
response.sendRedirect(”abc.jsp”);
return;

Read Full Post | Make a Comment ( None so far )

How can you set the session timeout in tomcat higher?

Posted on July 4, 2008. Filed under: Java | Tags: , |

You can specify the timeout of a session in the deployment descriptor of your web application (web.xml):
<web-app>
<session-config>
<session-timeout>60</session-timeout>
</session-config>


</web-app>
The number within the session-timout element must be expressed in minutes.

Read Full Post | Make a Comment ( 1 so far )

Integrating Apache 1.3.x and Tomcat 4.x with mod_jk on Linux

Posted on July 2, 2008. Filed under: Apache, Java | Tags: , , |

This FlashGuideTM covers integrating Apache 1.3.x and Tomcat 4.x on Unix via mod_jk. These instructions have been tested on SuSE 9.0, Red Hat 6.2 and Fedora Core 2. There are two ways to integrate Apache and Tomcat: mod_jk and mod_jk2. Mod_jk is the older but more stable version, which supports load balancing and non-standard web [...]

Read Full Post | Make a Comment ( 1 so far )

HttpSessionListener in Servlets

Posted on June 12, 2008. Filed under: Java | Tags: |

public interface HttpSessionListener
extends java.util.EventListener

Implementations of this interface are notified of changes to the list of active sessions in a web application. To receive notification events, the implementation class must be configured in the deployment descriptor for the web application.
sessionCreated
public void sessionCreated(HttpSessionEvent se)
Notification that a session was created.
Parameters:
se - the notification event
sessionDestroyed
public [...]

Read Full Post | Make a Comment ( None so far )

Cookie in Java

Posted on June 12, 2008. Filed under: Java | Tags: |

public class Cookie
extends java.lang.Object
implements java.lang.Cloneable

Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. A cookie’s value can uniquely identify a client, so cookies are commonly used for session management.
A cookie has a [...]

Read Full Post | Make a Comment ( None so far )

Escape special chars fom String- Mysql

Posted on May 31, 2008. Filed under: Java | Tags: |

Class StringEscapeUtils
java.lang.Object
extended by org.apache.commons.lang.StringEscapeUtils
public class StringEscapeUtils
extends java.lang.Object
Escapes and unescapes Strings for Java, Java Script, HTML, XML, and SQL.
escapeJava
public static void escapeJava(java.io.Writer out,
java.lang.String str)
throws java.io.IOException
Escapes the characters in a String using Java String rules to a Writer.
A null string input has no effect.
Parameters:
out - Writer to write escaped string into
str - String to escape values in, [...]

Read Full Post | Make a Comment ( None so far )

Retrieving Values from Result Sets

Posted on May 28, 2008. Filed under: Java | Tags: |

The ResultSet interface provides methods for retrieving and manipulating the results of executed queries, and ResultSet objects can have different functionality and characteristics. These characteristics are result set type, result set concurrency, and cursor holdability. A table of data representing a database result set is usually generated by executing a statement that queries the database.
The [...]

Read Full Post | Make a Comment ( None so far )

JDBC Introduction

Posted on May 28, 2008. Filed under: Java | Tags: |

The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database.
JDBC helps you to write java applications that manage these three programming activities:

Connect to a data source, like a database
Send queries and update statements to the database [...]

Read Full Post | Make a Comment ( None so far )

Resizes jpeg image files

Posted on January 1, 2008. Filed under: Java | Tags: |

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import com.sun.image.codec.jpeg.*;
/**
* Resizes jpeg image files on your file system.
* Uses the com.sun.image.codec.jpeg package shipped
* by Sun with Java 2 Standard Edition.
*
* @author Randy Belknap
*/
public class Resize extends Panel {
/**
* @param originalImage the file name of the image to resize
* @param newImage the new file name for the resized image
* @param factor [...]

Read Full Post | Make a Comment ( None so far )