Sunday, June 14, 2009

Important Struts Interview Questions

Important Struts Interview Questions
1) What is struts and what does struts constitute of?
2) What is ActionServlet?
3) Explain control flow in struts.
4) What are the tld files that comes packaged with struts?
5) What is ActionForm class?
6) What are Action class?
7) Difference between ActionServlet and Action class?
8)How data flows from user interface to the model layer and how does it come back to the view layer ?
9) What is struts-config.xml?
10) How to write action mapping?
11)What is the use of the properties file in struts?
12)How do we use validator framework?

Click for private tuition by a professional

Getting Database Connection Using JNDI and JDBC Datasource in Tomcat


Tomcat 5 provides a JNDI InitialContext implementation instance for each web application running under it, in a manner that is compatible with those provided by a Java2 Enterprise Edition application server. The J2EE standard provides a standard set of elements in the /WEB-INF/web.xmlfile to reference resources; resources referenced in these elements must be defined in an application-server-specific configuration.
For Tomcat 5, these entries in per-web-application InitialContext are configured in the elements that can be specified in either$CATALINA_HOME/conf/server.xml or, preferably, the per-web-application context XML file (either META-INF/context.xml).
The InitialContext is configured as a web application is initially deployed, and is made available to web application components (for read-only access). All configured entries and resources are placed in the java:comp/env portion of the JNDI namespace, so a typical access to a resource - in this case, to a JDBC DataSource - would look something like this:

// Obtain our environment naming context
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");

// Look up our data source
DataSource ds = (DataSource) envCtx.lookup("jdbc/EmployeeDB");

// Allocate and use a connection from the pool

Connection conn = ds.getConnection();
... use this connection to access the database ...

conn.close();


To configure Tomcat's resource factory, add an elements like this to the $CATALINA_HOME/conf/server.xml file, nested inside the Context element for this web application.
...

<Resource name="jdbc/db1"
auth
="Container" type="javax.sql.DataSource"
maxActive
="100" maxIdle="30" maxWait="10000" username="root"
password
="anu" driverClassName="com.mysql.jdbc.Driver"
url
="jdbc:mysql://localhost:3306/DB1?autoReconnect=true" />


Click for private tuition by a professional

Saturday, June 13, 2009

Using Free Custom Html Editor in Jsp FCK Editor

One of the best free html editor that we can incorporate in our jsp website is the FCK Editor.








We have to download the Java integration package from FCK editor site. Then place the jar files in our lib folder of our jsp application.
Then download the FCK editor and create a folder in our application in the root directory and place the FCK editor folder.
Then Place the FCK tld file in the WEB-INF folder and place the taglib directive in the jsp page where you want to use the editor.

Click for private tuition by a professional

Friday, June 12, 2009

Free Hadoop Tutorial Links



http://wiki.apache.org/hadoop/
http://pages.cs.brandeis.edu/~cs147a/lab/hadoop-example/
http://ebiquity.umbc.edu/.../hadoop-on-windows-with-eclipse/ 
www.cs.virginia.edu/~cbs6n/hadoop/HadoopTutorial.ppt


Thursday, June 11, 2009

Free Tutorial Ejb Ql For Jboss

How to Run Java Program involving Packages by Setting Classpath

Packages and Classpath:

Lets see how to compile a Java program using packages from command line

First we created a folder 'Pac1' in D: drive.Inside 'Pac1' we created another folder called 'Pac2' and inside 'Pac2' we created another folder called 'Pac3'

Java Program : Write or copy the following code in notepad and save the file as A.java

A.java
package pac2.pac3;


Class A
{
public static void main(String[] args)
{
System.out.println("Welcome to Packages");
}
}



Method-1: Executing Java program using packages
through command line


Go to Command Prompt

For compiling Java Program:

D:\Pac1>javac Pac2\Pac3\A.java
So here we have to go to the root folder to compile the program

For running/executing the java program:

D:\Pac1>java Pac2.Pac3.A
Welcome to Packages //Output displayed

The above method will not work unless the class path has a '.' in the classpath of environment variables.See below how to set the classpath


Setting the CLASSPATH:
Definition: Classpath is that environment variables which Java thinks contains the root of the package hierarchy
i.e Java starts to search from all the paths that is present in classpath

Go to Start> Right Click My Computer>Properties>Advance System Settings>Click Environment variables>Edit the Classpath
Add the (.;) in the beginning of classpath

(.;) : The '.' (Dot) will tell Java to search for the Java program from the current folder



Method-2:
Executing Java program using packages through command line


Instead of going through all the above process.There is a easier method to set the classpath in environment variables

Go to Start> Right Click My Computer>Properties>Advance System Settings>Click Environment variables>Edit the Classpath
Add 'D:\Pac1;' in the beginning of classpath

This is telling Java to start search from 'D:\Pac1' folder, even if you somewhere in E or F or other drive or folder

This will allow you to run the Java program from any drive or folder from the command line

Click for private tuition by a professional

Very Useful & Important Eclipse Shortcuts

syso + ctrl+ space--------------->System.out.println("");

ctrl + shift+ L-------------------->Shows all the Eclipse ShortCuts to the right bottom of eclipse window.

ctrl + shift+ T-------------------->Helps to search or look for any inbuilt classes interfaces or user defined classes or interfaces in eclipse workspace.

alt + shift+ R--------------------->Renaming any class,interface.

ctrl+3----------------------------> Very useful eclipse shortcut. You can do any thing using the shortcut. Once you pressed the keys a window appears where u can type like(" new project" or compile class) anything you want to do and eclipse will guide you.

ctrl+shift+f--------
---------------> Helps in formating. Or makes the code indended.


Click for private tuition by a professional