Best viewed in 1024 X 800 resolution... Leave a comment if u like an article...
Google
 
Web tezcols.blogspot.com

Wednesday, December 16, 2009

Some Java EE6 Updates

Contexts and Dependency Injection for the Java EE Platform

CDI unifies and simplifies the EJB and JSF programming models. It allows enterprise beans to replace JSF managed beans in a JSF application.

Bean Validation

To meet the objective of sharing the same set of validations across all the layers of an application, Bean Validation is integrated across the Java EE 6 platform.

public class Address {

@NotNull @Size(max=30)

private String addressline1;

@Size(max=30)

private String addressline2;

...

public String getAddressline1() {

return addressline1;

}

public void setAddressline1(String addressline1) {

this.addressline1 = addressline1;

}

...

}

==========è Customized Validation

   @Size(min=5, max=5)
   @ConstraintValidator(ZipcodeValidator.class)
   @Documented
   @Target({ANNOTATION_TYPE, METHOD, FIELD})
   @Retention(RUNTIME)
   public @interface ZipCode {
       String message() default "Wrong zipcode";
       String[] groups() default {};
   }

An object graph is an object composed of other objects. If you specify the @Valid annotation on the root object of an object graph, it directs the pertinent validator to recursively validate the associated objects in the object graph. Consider the following example:

public class Order {

@OrderNumber private String orderNumber;

@Valid @NotNull private Address delivery;

}

When an Order object is validated, the Address object and the associated objects in its object graph are validated too.

Support for Web Fragments in Servlet 3.0

Now we can have logical divisions of web.xml configurations. Not just in web.xml that way we can maintain a web-fragment file for each framework (Configuring Listeners, Servlets).

web.xml

webfragment1

webfragment2

The following annotations are applicable starting from Servlet 3.0 specification,

· @WebServlet

· @WebServletContextListener

· @ServletFilter

· @InitParam

package net.javabeat.servlet30.newfeatures;

import javax.servlet.annotation.InitParam;

import javax.servlet.annotation.WebServlet;

@WebServlet(

name = "SimpleServlet",

urlPatterns = {"/simple"},

initParams = {

@InitParam(name = "param1", value = "value1"),

@InitParam(name = "param2", value = "value2")}

)

public class SimpleServlet {

}

Some improvements made in EJB 3.1 are as follows:

  • No-interface view. Allows you to specify an enterprise bean using only a bean class without having to write a separate business interface. (If using EJBs locally)
  • Singletons. Lets you easily share state between multiple instances of an enterprise bean component or between multiple enterprise bean components in an application.
  • Asynchronous session bean invocation. Enables you to invoke session bean methods asynchronously by specifying an annotation. (@Asynchronous, Future , javax.ejb.AsyncResult)
  • Simplified Packaging. Removes the restriction that enterprise bean classes must be packaged in an ejb-jar file. You can now place EJB classes directly in a WAR file. (Looks like Tomcat can also exec EJBs now... hehe)
  • EJB Lite. Is a subset of EJB 3.1 for inclusion in a variety of Java EE profiles.

Labels:

Saturday, June 30, 2007

Can't start a cloned connection while in manual transaction mode

While using the Microsoft SQL Server 2000 Driver for JDBC, you may experience the following exception when you try to create multiple Statement objects with same Connection object:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Can't start a cloned connection while in manual transaction mode.

Add
SelectMethod=Cursor; in the connection string. Thats it..... Let me know if this helped u...

Friday, April 06, 2007

Bookmark using javascript....

< html >
< head >

< script language="JavaScript" type="Text/Javascript" >

var urlAddress = "http://www.talimpu.com";
var visibleName = "Mouth watering recipes...";
function addToFavorites() {
if(window.sidebar) {
window.sidebar.addPanel(visibleName, urlAddress,"");
}
if (window.external) {
window.external.AddFavorite(urlAddress,visibleName);
}

}
< /script >
< /head >

< body>
< a href="javascript:addToFavorites()"> < font color="#0000FF" face="Arial" > Wanna Bookmark me !< /font > < /a >
< /body >
< /html >

Labels:

Saturday, February 24, 2007

javascript to PRINT your webpage....

Many times programmers / web-designers need to print a receipt after a particular transaction... I have found many of them embedding ActiveX control for printing mechanism in their pages... activex control code looks awkward, class id is to be remembered, wil not wrk fine on all explorers....

here is a simple solution.... use
self.print() function in onclick method of a button which prints the page having the button...

The button will be hidden before printing in the code given below....

< html >
< body >

< form name='prnttest' >
this html prints the page... < br/ >< b >hides the button before printing < /br >

< table >
< tr >< td >
1< input type='radio' name='hh' value='1' >
< /td >< /tr >

< tr >< td >
2< input type='radio' name='hh' value='2' >
< /td >< /tr >
< tr >< td >
3< input type='radio' name='hh' value='3' >
< /td >< /tr >
< tr >< td >
4< input type='radio' name='hh' value='4' >
< /td >< /tr >
< /table >

< input type='button' value='Print' onclick="this.style.visibility='hidden';self.print();"/ >
< /form >
< /body >
< /html >

share ur experiences if this helps you....

tezcols

Labels:

Wednesday, February 21, 2007

Log ur activities easily....

for pals who use Windows operating system....

create a notepad file, the one which has .txt as extension on your desktop. Now open the file and write .LOG in the first line. Press enter key after writing. Close the file by saving changes.

If you open the file now, you will find the current date and time followed by a cursor waiting for your log :-) Close n Open Close n Open Close Open.... everytime u can write a log....

tezcols

Labels:

Tuesday, February 13, 2007

TOMCAT IIS CONNECTOR

Is your superior asking you to deploy Java stuff on IIS ? Are you using TOMCAT web server instead ?

uhhhh... don't bother... u got it...

Im gonna tell u connecting tomcat webserver to IIS. Requests that need java engine will be forwarded from IIS to tomcat and get the response without the knowledge of the web user.

I guess u hav

I am using Windows XP and I have

  • J2SDK installed at C:\Program Files\Java\jdk1.6.0
  • Tomcat installed at C:\Program Files\Apache Software Foundation\Tomcat 5.0 with default port 8080 configured.
  • CATALINA_HOME and JAVA_HOME environment variables (System Variables) configured.
  • Make sure that no other application is running on port 80 so that IIS can run on its default port 80. Change the port numbers and make sure of the IIS port number being used.

Extract the connectors-jk2.0.4-win32-IIS.zip and copy isapi_redirector2.dll to TOMCAT_HOME/bin/win32/i386. If you dont have the win32 and i386 folders just create new one and then copy to i386.


To support the JK2 Connector, you might need to edit the jk2.properties file. In most cases though, the default settings adopted by Tomcat are correct and the contents of jk2.properties can remain commented out.You can find jk2.properties in TOMCAT_HOME/conf directory. If you don't have one jus create a file with the name jk2.properties and copy the following text into the jk2.properties file


## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED

## WHEN YOU EDIT THE FILE.

## COMMENTS WILL BE _LOST_

## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.

# Set the desired handler list

# handler.list=apr,request,channelJni

#

# Override the default port for the socketChannel

# channelSocket.port=8019

# Default:

# channelUnix.file=${jkHome}/work/jk2.socket

# Just to check if the the config is working

# shm.file=${jkHome}/work/jk2.shm

# In order to enable jni use any channelJni directive

# channelJni.disabled = 0

# And one of the following directives:

# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so

# If set to inprocess the mod_jk2 will Register natives itself

# This will enable the starting of the Tomcat from mod_jk2

# apr.jniModeSo=inprocess


Now create a file with the name workers2.properties if you dont have and copy the following into the file


[shm:]info=Shared memory file. Required for multiprocess servers

file=C:\Program Files\Apache Software Foundation\Tomcat 5.0\jk2.shm

size=1000000

[channel.socket:localhost:8009]

info=Ajp13 worker, connects to tomcat instance using AJP 1.3 protocol

tomcatId=localhost:8009

[uri:/jsp-examples/*]

info=JSP examples, map requests for all JSP pages to Tomcat.

context=/jsp-examples


The IIS redirects every request to 'context' attribute mentioned above.Requests to

http://localhost/jsp-examples/ (IIS) will be redirected to http://localhost:8080/jsp-examples/ (Tomcat server). You can include more than one context attribute from the next line.

Now some settings to the Windows Registry are to be made so that the redirector will read when it is loaded by the IIS.
create a file with the name isaapi_redirector2.reg preferably in TOMCAT_HOME\bin\win32\i386. Right click and select edit. Copy the following text into it.


Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\2.0]

"workersFile"="C:\\Program Files\\Apache Software Foundation\\Tomcat 5.0\\conf\\workers2.properties"

"extensionUri"="/jakarta/isapi_redirector2.dll"

"logLevel"="debug"

"serverRoot"="C:\\Program Files\\Apache Software Foundation\\Tomcat 5.0\\"

Before saving make sure that 'workersFile' attribute points to the workers2.properties just created and 'serverRoot' points to your tomcat home directory. Save the file. Again right click and select Merge.

If you dont have IIS installed go to Control panel ---- Add or Remove Programs ---- Add/Remove Windows Components---- enable Internet Information Services (IIS) and install.
Now go to Control panel --- Administrative Tools and launch Internet Information Services.
Expand the tree LOcal Computer and you wil find 'Web Sites'.Right click on it and select 'Properties'. Now select 'ISAPI Filters' tab. Click Add button. Enter the Filter Name (Tomcat Connector) and Browse for isapi_redirector2.dll. Click OK and Apply on ISAPI Filters tab.
Expand the 'Web Sites' node and u wil find 'Default Website'. Right click on it and create a virtual directory with the name 'jakarta' in TOMCAT_HOME\bin\win32\i386. Click Next and ensure that Execute is checked. Click Next.

Set Tomcat Server to auto start. To do this do it through services.exe or right click on the tomcat icon at the taskbar and check Auto start option.
Right click on the 'local computer' node in IIS ---- All tasks --- Restart IIS. Click OK
Thats it......
Try

http://localhost:8080/jsp-examples/ by typing in you explorer.The response given is directly from Tomcat.Now try http://localhost/jsp-examples/ . The same response will be given through IIS.Change the port number in the addresses if required.

Send me a comment if this article helped u...

tezcols


Labels:

Wednesday, November 15, 2006

unselectable attribute in HTML

Hey !! wil u bliv if i say tht HTMl has an attribute named 'unselectable'. This attribute can make an element not to be selectable. Let me tel clearly. 4 suppos u hav a HTML table n a no. of td tags in it. A part of text in a td can be selected by dragging on the desired part. Try settin unselectable="on" in td tag. The magic cums in. You cannot select a part of text now in that td. Not jus in td tag. U can use it in span,div...... etc.

U can set the 'unselectable' attribute to either 'on' or 'off'. The default value for an unselectable attribute in an HTML element is set to 'off'.

Nice tip na...

k bye...

tezcols

Labels: