Navigation Bar

Thursday, April 29, 2010

Deploy and Debug Struts 1.1 in Eclipse IDE

Create a blank folder say "E:\workspace"

File -> New -> Project -> Dynamic Web Project

 

Click on Finish.

 

 

In the workspace3 folder a WEB-INF folder is created.

Place the LookupAction.java and LookupForm.java files in the src folder path which is created.

In the Action class and Form class see the package directory path in which the class files will get created. Create the same folder paths in the src folder for getquote project.

 

DirectoryContains
/getquote/WebContentThe root directory of the web application. All JSP and HTML files are stored here
getquote/WebContent/WEB-INFThis directory contains all resources related to the application that are not in the document root of the application. It is where the web application deployment descriptor is located
getquote/WebContent/WEB-INF/classesThis is where the servlet and other classes are located.
getquote/WebContent/WEB-INF/libThis directory contains Java Archive (JAR) files that the web application is dependent on
getquote/WebContent/srcThe directory having the java source code.

We place the .java file in the folder /getquote/WebContent/src folder as below
 
We place the jsp files in the /getquote/WebContent/ folder as below
We place the web.xml , the .tld files and the struts-config.xml files in the /getquote/WebContent/WEB-INF folder as below.
 
We place the .jar files in the  /getquote/WebContent/WEB-INF/lib folder.

In "Project Explorer", if we refresh the getquote project, we should be able to see all the struts objects in their respective folders.
We now set the paths for the JRE folder, the TOMCAT web server and the paths for the JAR fules.

In Windows -> preferences -> Java -> Installed JREs click on the Add button and slect the folder path for JAVA.


For Tomcat, in Windows -> preferences -> Tomcat, select the Tomcat version you are using.
For Tomcat Home, browse and select the path for the Tomcat installation.
For Contexts directory, browse and select TOMCAT_HOME/conf/Catalina/localhost.
 
 

 
We now set the path for the JAR files which will be referenced by the Web application.
The JAR files referenced by the application are the struts jars, the TOMCAT jars and the JAVA JRE installed jars. 
 
In Project -> Properties -> Java build path -> Libraries, click on Add External JARs.
For the Struts JARs, browse to the lib folder of your Struts 1.1 extract and select the list of applicable JARs.
For the Tomcat JARs, browse to the lib folder of TOMCAT_HOME and select the list of applicable JARs.



For the JRE JARs, click on Add library and select JRE System Library. This will select all the jars from JAVA_HOME/jre/lib folder.




We now set the path for the src folder and the output folder for the java class files.
In Project -> Properties -> Java build path -> Source tab, click on Add Folder and select the folder path for the .java files of your web application.
For the output folder, in the Browse tab select "E:\workspace3\getquote\WebContent\WEB-INF\classes" and click on the checkbox, "Allow output folders for source folders".
 




 
You can now click on Project -> Build Project to build your web application.
If all setup has been done as described above, build should happen successfully without any errors. 
 
To run the application, in Project Explorer, right click on the getquote project, 
Run as and Run on server.
 














 
 

No comments:

Post a Comment