Saturday, May 28, 2005

jsse tips

1. To add public key to keystore from certificat file (*.pem, *.der, *.cer) is as below:
keytool -import -alias myalias -file certfile -keypass passwd -keystore storename -storepass passwd

2. To start a java client with debug info is:
java javaclient

3. Use the below java code that works with point #2 above.

SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket("localhost", 443).

rest of the code is standard to get output stream and use buffered reader.

4. an alternate approach is at javaworld article

Sunday, May 15, 2005

IBM portlet programming interview questions

What is the difference between a servlet and a portlet?
Portlet is basically an extension of servlet but with some fundamental differences like a web page can consist of mulitple portlets but can have only single servlet, portlets cannot do browser redirect but servlet can.

What are the similarities between a servlet and a portlet?
Portlet is a an extension of servlet, can write html output, can forward but within the same portlet context, access to HTTP objects like session, request, response, along with similar Portlet objects like session, request, response.

What is WSRP?
Web Services Remote Portlet.

What are the different approaches for logging in portlet?
Websphere log apis, log4j, custom logging, jdk1.4 log apis and any logging framework should work just as well.

What are the different approaches for managing environment specific configuration?
Properties file, portlet attributes (configured via the config-param in portlet.xml).

Difference between abstract portlet and concrete portlet?

Explain struts portlet. How to create one?
Create a struts standalone web app and convert to portlet. There are 8-10 steps to do so.

Explain JSR168 portlet. How to create one?
Use WSAD wizard.

What is the difference between HTTPRequest and PortletRequest?
HTTPRequest is for the entire portal page and portlet request is abstracted out of HTTPRequest and is unique per portlet. As best practises portlet code should use PortletRequest object.

Should you use class scoped variables in portlet?
No, single instance of portlet in the JVM and so can cause data corruption if variable values are changed. However, no harm in using "final static" singleton kind of variables.

Can you do browser redirects from the portlet?
No, only forward.

What does the tag <portletApi:init /> do?
Initializes portletRequest, portletResponse, etc on the page.

What are the different portlet states?
Maximize, Normak, Minimize.

What are the different portlet modes?
View, Edit, Configure, Help.

Portlets execute in two steps, what are those?
Action and render in portal 5.0. There is a new phase IStrutsPrepareRendor introduced in portal 5.1 to address browser refresh, back, etc issue.

How to access external systems from portlet code like database, credential vault, and ftp server?

What is portal service?


There is pattern everywhere or should we say everything is a pattern. It is patterned that mango seed will grow into a mango plant, baby into a grown up, and so on. These patterns exist in nature. We also tend to do things in pattern, cars are mass produced in patterns, we invented patterns to build buildings and bridges. There are also patterns in the software world like Facade and DAO (Data Access Object).

But it looks like that sometimes there could be anamolies in the patterns. The patterns may not be perfect, there may be disadvantages, or they may not be just right. In the software world there is something called anti-patterns. Sometimes in nature we see malformed plants and animals which does not seem to conform to intended behavior of pattern.