servlet 2.5
1. Servlet name wildcardingFirst, when writing a <filter-mapping>, you can now use an asterisk in a <servlet-name> entry to represent all servlets (and thus all JSP pages as well). Previously, you could only bind one servlet at a time to a filter, like this:
<filter-mapping>
<filter-name>Image Filter</filter-name>
<servlet-name>ImageServlet</servlet-name>
</filter-mapping>
Now you can bind all servlets at once:
<filter-mapping>
<filter-name>Image Filter</filter-name>
<servlet-name>*</servlet-name> <!-- New -->
</filter-mapping>
2. Multiple patterns in mappings
Second, when writing a <servlet-mapping> or <filter-mapping>, you can now provide multiple match criteria in the same entry. A <servlet-mapping> previously supported just one <url-pattern> element. Now it supports more than one.
For example:
<servlet-mapping>
<servlet-name>color</servlet-name>
<url-pattern>/color/*</url-pattern>
<url-pattern>/colour/*</url-pattern>
</servlet-mapping>
3. Likewise, a <filter-mapping> previously allowed just one <url-pattern> or one <servlet-name>. Now it supports any number of each:
<filter-mapping>
<filter-name>Multipe Mappings Filter</filter-name>
<url-pattern>/foo/*</url-pattern>
<servlet-name>Servlet1</servlet-name>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/bar/*</url-pattern>
</filter-mapping>
4. A new dependency on J2SE 5.0
5. Support for annotations and Annotation performanceWhether or not you use annotations—and especially if you don't—it's important to understand the performance impact they can have on a server at startup. In order for the server to discover annotations on classes, it must load the classes, which means that at startup, a server will look through all the classes in WEB-INF/classes and WEB-INF/lib, looking for annotations. (Per the specification, servers don't have to look outside these two places.) You can avoid this search when you know you don't have any annotations by specifying a metadata-complete attribute on the <web-app> root like this:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
version="2.5" metadata-complete="true">
</web-app>
When you're not using annotations, this reenables lazy class loading.
Annotations:
JSR 250: Common Annotations for the Java Platform
JSR 220: Enterprise JavaBeans 3.0
JSR 224: Java API for XML-Based Web Services (JAX-WS) 2.0
JSR 181: Web Services Metadata for the Java Platform
6. A handful of removed restrictions
Servlet 2.5 eased a few restrictions around error handling and session tracking. With error handling, Servlet 2.5 removed a rule dictating that error-handling pages configured with <error-page> could not call setStatus() to alter the error code that triggered them. The rule followed the argument that the job of an error page is to report each error but not alter it. However, practical use has made clear that sometimes an error-handling page may be able to do something more graceful than show an error, perhaps choosing instead to show an online help chat window to help the user resolve the problem. The specification no longer prevents an error-page handler from producing a nonerror response.
Regarding session tracking, Servlet 2.5 eased a rule dictating that a servlet called by RequestDispatcher include() couldn't set response headers. This rule's purpose was to keep included servlets constrained within their own space on the page, unable to affect the page outside that area. The rule has eased now to allow request.getSession() calls within the included servlet, which might implicitly create a session-tracking cookie header. Logic dictates an included resource should be constrained, but logic also dictates those constraints shouldn't eliminate the ability to initiate a session. This change proves especially important for the Portlet Specification. Note that if the response was already committed, the getSession() call will throw an IllegalStateException. Previously, it would have been a no-op.
7. Some edge case clarifications
Lastly, the new specification clarifies several edge cases to make servlets more portable and guaranteed to work as desired.
Response closureThe first clarification is trivial and esoteric, but interesting as an example of the unintended side effects you sometimes see in a specification. The Servlet 2.4 specification dictates that the response should be committed (that is, have the response started with the status code and headers sent to the client) in several situations including when "The amount of content specified in the setContentLength method of the response and has been written to the response." This appears all well and good until you write code like this to do a redirect:
response.setHeader("Host", "localhost");
response.setHeader("Pragma", "no-cache");
response.setHeader("Content-Length", "0");
response.setHeader("Location", "http://www.apache.org");
Sunday, August 12, 2007
Thursday, August 9, 2007
PHP4 installation on apache2 (require root permission)
Download the php binary distribution from php site and execute the following commands in the same order
$gzip -d php-4.4.4.tar.gz
$tar -xvf php-4.4.4.tar
$cd php-4.4.4
$./configure --with-apxs2=/portal/apache0/bin/apxs --with-config-file-path=/portal/apache0/conf
$make
$make install
$cp php.ini-dist /portal/apache0/conf/php.ini
edit httpd.conf and add below lines
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
restart apache
$gzip -d php-4.4.4.tar.gz
$tar -xvf php-4.4.4.tar
$cd php-4.4.4
$./configure --with-apxs2=/portal/apache0/bin/apxs --with-config-file-path=/portal/apache0/conf
$make
$make install
$cp php.ini-dist /portal/apache0/conf/php.ini
edit httpd.conf and add below lines
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
restart apache
some useful unix commands
Free Memory check
$ free -m
Free Memory and Total Memory check
$ free -m -t
Process wise memory usage
$ vmstat
$ top (hit q to stop)
To get to know the environment
$ env
$ free -m
Free Memory and Total Memory check
$ free -m -t
Process wise memory usage
$ vmstat
$ top (hit q to stop)
To get to know the environment
$ env
Oracle double byte characters sets
If your operating system is enabled for a single-byte character set, it does not automatically accept double-byte character sets. You must enable your database to store monitoring information that comes in double-byte character strings.
So while creating a database includes the CHARACTER SET UTF8 string. This string enables storage of double-byte character sets.
Enabling the database for double bytes character set is just setting the character set to UTF-8.
To make sure the database is UTF-8 enabled execute the below query.
select value from NLS_DATABASE_PARAMETERS where parameter = 'NLS_CHARACTERSET';
result 1: WE8ISO8859P1
result 2: AL32UTF8
If you get UTF8 then it is UTF-8 enabled
So while creating a database includes the CHARACTER SET UTF8 string. This string enables storage of double-byte character sets.
Enabling the database for double bytes character set is just setting the character set to UTF-8.
To make sure the database is UTF-8 enabled execute the below query.
select value from NLS_DATABASE_PARAMETERS where parameter = 'NLS_CHARACTERSET';
result 1: WE8ISO8859P1
result 2: AL32UTF8
If you get UTF8 then it is UTF-8 enabled
UnsupportedClassVersionError
Java version incompatible error
Caused by: java.lang.UnsupportedClassVersionError: com/mycomp/struts/GetNameForm (Unsupported major.minor version 49.0)
If you compile this java file using jdk1.5 and try to run it on jdk1.4.2 (lower version) u'll get this error !!
Caused by: java.lang.UnsupportedClassVersionError: com/mycomp/struts/GetNameForm (Unsupported major.minor version 49.0)
If you compile this java file using jdk1.5 and try to run it on jdk1.4.2 (lower version) u'll get this error !!
UNIX command to run script as a backend process
example 1: nohup java Reminder &
example 2: nohup ./start.sh &
example 2: nohup ./start.sh &
Oracle Performance Issue
Using function in the query will get the performance issue (increase the loading time)
lets take a table has got more than 1000 records
example:
SELECT * FROM EMP WHERE UPPER(NAME) = UPPER('ram') takes 15secs
whereas
SELECT * FROM EMP WHERE NAME = 'ram' takes less than a sec
lets take a table has got more than 1000 records
example:
SELECT * FROM EMP WHERE UPPER(NAME) = UPPER('ram') takes 15secs
whereas
SELECT * FROM EMP WHERE NAME = 'ram' takes less than a sec
request scope attributes
request scope attributes for include and forward.
While doing include or forward by default following attributes will get populated. Below are them respectively.
javax.servlet.include.request_uri
javax.servlet.include.servlet_path
javax.servlet.include.context_path
javax.servlet.include.path_info
javax.servlet.include.query_string
javax.servlet.forward.request_uri
javax.servlet.forward.servlet_path
javax.servlet.forward.path_info
javax.servlet.forward.query_string
To access the attributes
Servlet / JSP: request.getAttribute("javax.servlet.include.request_uri")
EL: requestScope['javax.servlet.include.request_uri'] or ${requestScope.javax.servlet.include.request_uri}
While doing include or forward by default following attributes will get populated. Below are them respectively.
javax.servlet.include.request_uri
javax.servlet.include.servlet_path
javax.servlet.include.context_path
javax.servlet.include.path_info
javax.servlet.include.query_string
javax.servlet.forward.request_uri
javax.servlet.forward.servlet_path
javax.servlet.forward.path_info
javax.servlet.forward.query_string
To access the attributes
Servlet / JSP: request.getAttribute("javax.servlet.include.request_uri")
EL: requestScope['javax.servlet.include.request_uri'] or ${requestScope.javax.servlet.include.request_uri}
CHMOD
A combination of:
And combination of:
with the Permissions:
one of the following to copy permissions:
to have read/write access to everyone to the temp folder
- u user (file owner)
- g group
- o others
- a all (same as ugo)
And combination of:
- r read
- w write
- x execute
with the Permissions:
- = assigned
- + added
- - subtracted
one of the following to copy permissions:
- u user
- g group
- o other
- s
to have read/write access to everyone to the temp folder
Lotus Notes - Javamail gotcha
Any javamail generated message body (text/html) content doesn't allowed to have form fields. If you want to have a form field then you must follow either of two things.
1. use <input type='image' width='0' height='0' src=''/>
2. change your email message to edit mode
1. use <input type='image' width='0' height='0' src=''/>
2. change your email message to edit mode
Java EE 5 Architect
Sun recently conducted the survey to release the Java Architect certification on Java EE 5 platform. Tentativly scheduled in September 2007. Here is the snapshot of sections covered.
1. Application Design Concepts and Principles
2. Common Architecture
3. Integration and Messaging
4. Business Tier Technologies
5. Web Tier Technologies
6. Applicability of Java EE Technology
7. Patterns
8. Security
1. Application Design Concepts and Principles
2. Common Architecture
3. Integration and Messaging
4. Business Tier Technologies
5. Web Tier Technologies
6. Applicability of Java EE Technology
7. Patterns
8. Security
Subscribe to:
Posts (Atom)