Sunday, January 29, 2006

How to handle back browser button caching?

You can figure it out here and here

How to keeping track of Logged users?

You can find it here

Friday, January 27, 2006

How to find whether a Object bound to session scope has expired (or) not.

jsp:useBean id="Perfumes" class="Perfume.Perf" scope="session"/

NOT the correct way to go about.
<% if(Perfumes == null) { response.sendRedirect("http://localhost:8080/home.html"); } %>

Testing for expired sessions by testing the session object itself for nullness isn't always the most reliable way to go. This is especially true if you're using a useBean tag

The useBean tag will create a new session if the previous one has expired. So, your test for an exsiting session will return true, even though it isn't the same session that the user had when they originally logged in.

I've had much better luck testing for the existence of an object bound to session. When the user logs in sucessfully, create an object ("userBean") and bind it to session. Then with each hit, check to see if that object is null (filters are nice for this). If it is, forward or redirect to the login page.

Correct way.
if(null == session.getAttribute("userBean"){
// must be a new session...
// forward to login
}

Monday, January 09, 2006

Take a look at the new features added to Servlets 2.5 here

Thursday, January 05, 2006

Can we invoke a servlet from a Java class.

Learn about it here

Check "Applet To Servlet Communication" blog entry(second entry from this one) to find out how to use

java.net.URL
java.net.URLConnection, classes.

Can we execute a servlet from command prompt?

We can't run a servlet as a standalone java application from the command line, we can use a browser to invoke a servlet if it's running in a container.


Cross-Context Communication

Applet To Servlet Communication

A very good chapter(17) on this topic is available freely in Core Servlets and Jsp book.

Applet-to-Servlet Communication


Servlet - Applet Communication ==> Path Configuration.