Archive | Java / J2EE RSS feed for this section

JSTL Function in JSP 2.0

March 3, 2009

2 Comments

In JSP 2.0 we can perform string operations in JSP without using any java code inside scriptlets. This is possible with the latest release of JSTL 1.1. The new library called Functions with prefix as fn allows us to perform string operations in JSP 2.0. The following example explains all the string operation which we [...]

email

ServletContextListener Example

February 26, 2009

3 Comments

This tips explains the how to use ServletContextListener. There will be only one ServletContext for each web application. ServletContext will be created while deploying the application. Once the ServletContext is created, it will be used by all the servlets and jsp files in the same application. ServletContext is also called as the application scope variables [...]

Dynamic Attributes in Tag File in JSP 2.0

February 26, 2009

1 Comment

As we know that we can develop custom tag library as a simple tag file in JSP 2.0 and these tag files can accept attributes from the invoking JSP page. But one drawback of this approach is that we need to declare all the attributes in the tag file. JSP 2.0 provides a feature called [...]

Variable Directive in JSP 2.0 Custom Tags

February 25, 2009

0 Comments

This tips explains how to use the variable directive in the custom tags in JSP 2.0. There is time when JSP page needs to access the variable declared inside the Tag files. In the previous version we have to extend the tag library to declare the variables and need the special handling for those variables. [...]

Custom Tags in JSP 2.0

February 25, 2009

0 Comments

Tag Files in JSP 2.0 This tips explains about what are the advantages in the Custom Tags in JSP 2.0. It also compares it with the previous JSP versions. Lets look into the tips for more detail. Developing custom tags in the previous JSP versions are tedious and it is considered as one of the [...]

Custom Tag Libraries and Tag Files in JSP 2.0

February 25, 2009

0 Comments

With previous versions of JSP developing custom tag libraries was possible only by writing Java classes. As a result knowledge of Java was a must. JSP 2.0 introduces a new way of developing custom tag library using plain JSP. This enables JSP developers, who dont know Java, to develop custom tag libraries as Tag files. [...]

Error Pages in JSP 2.0

February 24, 2009

0 Comments

We can configure error pages in jsp and servlets to direct the control to a custom error page, showing a friendly error message to the user when an exception is thrown in the page. But tracking or logging the exception information is not very easy in JSP 1.2. JSP 2.0 fixes this problem by switching [...]

Ternary Operator in JSP 2.0 Expression Language(EL)

February 23, 2009

0 Comments

A very common need in a JSP page is to include a piece of template text only if a certain condition is true. With JSP 1.2 and JSTL 1.1, this is typically done using a block, but that’s a very verbose solution. JSP 2.0 adds a new conditional operator to the Expression Language(EL) to deal [...]

load-on-startup element in web.xml

February 17, 2009

0 Comments

This tips explains the few points on how to use the load-on-startup element on the web.xml file. When erver is starting, it is possible to tell the container to load a servlet on the startup. You can load any number of servlets on the startup. Normally this is done for any initialization purpose. Look into [...]

Servlets Interview Questions

February 13, 2009

1 Comment

1) Is it the “servlets” directory or the “servlet” directory? For Java Web Server: on the file system, it’s “servlets” c:\JavaWebServer1.1\servlets\DateServlet.class in a URL path, it’s “servlet” http://www.stinky.com/servlet/DateServlet 2) How do I support both GET and POST protocol from the same Servlet? The easy way is, just support POST, then have your doGet method call [...]