Wednesday, December 28, 2005

XML usage in Web Application

Uncover it here

Tuesday, December 27, 2005

AJAX and its Purpose

AJAX Article

AJAX Purpose

How to enable Auto-Refresh in JSP Pages and Servlet

In servlets we use response Headers to achieve Auto-Refresh
response.setIntHeader("Refresh",3);

In JSP pages we use META tags to achieve Auto-Refresh
META HTTP-EQUIV="Refresh"
CONTENT="5;URL=http://localhost:8080/SecurityCheck/Test1.html">

//
URL=http://localhost:8080/SecurityCheck/Test1.html --> NOT Mandatory.
5 -
Indicates the number of seconds after which the Page should refresh.

Auto servlet refresh

Monday, December 26, 2005

Tomcat Adminstration and Tomcat Manager


Entries that are to be made in "tomcat-users.xml" to facilitate access to Tomcat Manager and Admin

role rolename="admin"/>
role rolename="manager"/>
user username="vishnu" password="vishnu" roles="admin,manager"/>

username and password attribute values in "user" tag are user-defined(Can be anything)

Thursday, December 22, 2005

Simple and Classic Tags

Learn about it here and here

Thursday, December 15, 2005

Can we place a JSP file inside WEB-INF

It is perfectly valid to put a JSP file inside the WEB-INF to prevent direct access to clients, in that case, it is only accessible via forwards/includes.

The problem is that the jsp inside WEB-INF folder cannot access resources like images,scripts etc.The specification doesn't suggest anything in this regard, it is upto the web-server whether to consider the jsp or not.

How to access such a resource
Find about it Here

Wednesday, December 14, 2005

Why JSP can't implement interface?

Discover it here

Default Login Form

FORM action = "so" method = "post">
Name: INPUT type = "text" name = "username" />
Password: INPUT type = "password" name = "password" />
INPUT type = "submit" value = "submit" />
/FORM>


Either action attribute has to be fully qualified name including the application name and path (or) only path without any slash at the beginning.

Correct.
1. action="/ApplicationName/so"
2. action="so"
3. action="so/someExtraPath"

InCorrect
1. action="/so"

Tuesday, December 13, 2005

From where jspInit() is called ?

Locate it here

Monday, December 12, 2005

Where to place the tld files

Check it Here

Friday, December 09, 2005

Referer

How to find the request URL? For example if the request is made from
"http://localhost:8080/SecurityCheck/JspOne.jsp " this url, how to get it in the servlet code?

StringBuffer buffer = request.getRequestURL();
String str = new String(buffer);
System.out.println("RequestURL()" + str);


Is there a way to know from which page the request is coming. For example if I have a web application with 10 pages having a link to login page I like to know from which page the request to login page was made?

Referer:
It's an optional header field that contains the URL of the referring document.

The Referer field was designed for link backtracking and verification, not for authentication or session management.

request.getHeader("referer") will give you the source url
<%= request.getHeader("referer") %>


A very good article about referer is here

Take a look at this JavaRanch Thread to know why NOT to rely on referer Header.

Thursday, December 08, 2005

page and pageContext implicit Objects

Click Me

Friday, December 02, 2005

Default TLD File

?xml version="1.0" encoding="UTF-8"?>

taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">

tlib-version>1.2 /tlib-version>
short-name>vis /short-name>

/taglib>

Default web.xml file

?xml version="1.0" encoding="UTF-8"?>

web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

/web-app>

Thursday, December 01, 2005

JSTL - does it really make life simpler?

Find about it Here