Saturday, April 26, 2008

Basic Security on JAXWS 2.0

You can apply basic realm security to your webservice. In the web.xml, you have to paste certain tags given below. Don’t apply the Basic Realm for GET. The client code makes a GET request to get the port. Apply Basic Realm for POST. The client code will put the authentication values in the headers as:
 Calculator calculator = (new CalculatorService()).getCalculatorPort(); 
 BindingProvider provider = (BindingProvider) calculator; 
 provider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "navnit"); 
 provider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "leo");
The web.xml section is as below:

 
  Protected Site
  
  /*
  
  DELETE
  POST
  PUT
 
 
 
  
  CalculatorUser
 




 BASIC
 Example Basic Authentication




 Test role
 CalculatorUser

You also need to create a role in the tomcat-users.xml and a user/password.


Change the foreground and background selection color of a JMenuItem.

JCheckBoxMenuItem standard = new JCheckBoxMenuItem(); 
standard.setUI(new chkboxMenuItem(menuSelFore,menuSelBack)); 

class chkboxMenuItem extends BasicCheckBoxMenuItemUI { 
    public chkboxMenuItem(Color selFore,Color selBack) { 
        selectionForeground = selFore; 
        selectionBackground = selBack; 
    } 
}

Changing the swing submenu expanding orientation

To set the orientation of the menu to open the submenus in the left direction ( <-- ) instead of default right direction ( --> ) use :
JMenu prefMenu = new JMenu();
prefMenu.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

Wednesday, January 16, 2008

Using JAXWS 2.1 on Java 6.0

To use JAX-WS 2.1 on Java 6.0 and Tomcat 6.0, place all the libraries in the JAXWS 2.1 in “<TOMCAT_HOME>\endorsed” directory. To run the client, you have to have the JAX-WS 2.1 library (jaxb-api.jar) in your bootstrap. For this put the jaxb-api.jar from the JAX-WS 2.1 distribution in the "<JAVA_HOME>/jre/lib/"endorsed.

Friday, January 11, 2008

Why SiteMesh instead of Tiles?

  1. SiteMesh is much easier to configure and use (less typing and easier to understand)
  2. Using Tiles, you need to have your forwards go to a "tiles page" versus the direct JSP. SiteMesh takes the approach that your page (your JSP) doesn't even know or care that it's being decorated.
  3. Using Tiles, each individual page you want to go to has to be associated with a layout - Major pain! Every time you create a new JSP that you want to forward to, you have to create another tiles definition and associate it with a layout and forward to the Tile page (versus the JSP). With SiteMesh you can simply set up a URL pattern and all your pages are decorated with the layout you choose.
On the other hand there is downside of using SiteMesh. SiteMesh stores the entire content of your HTML body into memory before it decorates it. If you have some very large pages, such as might happen in a reporting application where you don't have pagination implemented and end up with one large page of rows, you could end up with severe memory problems.
You can read this http://today.java.net/pub/a/today/2004/03/11/sitemesh.html post by Will Iverson about how to use SiteMesh.