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.
 














Debugging the struts application in Eclipse
 
Open the LookupAction.java file. On the left pane of this file double click and add the debug point on the line where you want to debug the code.
In Package Explorer, right clik and Debug As -> Debug on Server.
This will open the url in the eclipse ide in debug mode. Now when you enter the Stock Symbol and click on Get Quote, the application debugging will be enabled.
For debug, F6  for step over, F5 for step into. The various options for debugging can be seen in the Run tab in Eclipse.






 

God's Word for the day 

A prayer for help against sinning
Who will set a guard over my mouth,
  and an effective seal upon my lips,
So that I may not fall because of them,
  and my tongue may not destroy me?
O Lord, Father and Master of my life,
  do not abandon me to their designs,
And do not let me fall because of them.
  Who will set whips over my thoughts,
And the discipline of wisdom over my mind,
  so as not to spare me in my errors,
and not overlook my sins?
  Otherwise my mistakes may be multiplied,
and my sins may abound,
  and I may fall before my adversaries,
and my enemy may rejoice over me.
  O Lord, Father and God of my life,
do not give me haughty eyes,
  and remove evil desire from me.
Let neither gluttony nor lust overcome me,
  and do not give me over to shameless passion.
Sirach 22:27, 23:1-6

Gospel teachings of Jesus

The Canaanite Woman's Faith
Jesus left that place and went away to the district of Tyre and Sidon.
  Just then a Canaanite woman from the region came out and started shouting,
"Have mercy on me Lord, Son of Daivd; My daughter is tormented by a demon."
  But he did not answer her at all. And his disciples came and urged him saying,
"Send her away, for she keeps shouting after us." He answered, "I was sent only
  to the lost sheep of Israel." But she came and knelt before him saying, "Lord,
  help me." He answered, "It is not fair to take the children's food and throw it
  to the dogs." She said, "Yes, Lord, yet even the dogs eat the crumbs that fall
  from their masters' table." Then Jesus answered her, "Woman great is your faith!
  Let it be done for you as you wish." And her daughter was healed instantly.
Mathew 15:21-28

No comments:

Post a Comment