Hi,
Note: Each and every step before doing read the important notes and follow . I give important notes in bottom.
1. Open a NetBeans editor.
2. Select the following method for create empty project.
File -> NewProject -> Web -> WebApplication
Next -> Give project name -> select project location
Next -> Select struts (check box).
Finish.
3. Designing form inside the index.jsp
Whatever you need (textbox,button,label etc…)
4. Create a new package under source package
Right click SourcePackage ->
Java Package -> Give the package name.
5. Create a new
formbean file
RightClick JavaPackage -> new -> StrutActionFormBean
Give the class name
6. Create a new action file
RightClick JavaPackage -> new -> StrutAction
Give the classname , Actionpath ** (classname must be equal ActionPath)
Select Request or Session .
7. Create a new java class for DBConnect
Database connection establishment coding here.
8. Java Script
Create a new Folder for javascript under Webpages.
Rightclick javascriptfolder -> new -> File/Folder
Next -> Other folder -> EmptyFile
Next -> Give name. -> Finish.
Important Notes:
3.1 Form Creation
Give the form action Name
Create a textbox, password field, button .
Note the FormName and Property
5.1 Form bean creation
The formbean name must be equal to form name.
Egs. Formbean name is TestForm.
Then the following coding inside the FormBean(TestForm)
Declare the following variables
Variables names and property names are must be equal.
Select all the above variables and right click
Refractor -> Encapsulate Fields.
Select get and set username, password, submit -> Next -> Do Refractoring.
6.1 Strut Action creation
The strut action name and form action name must be equal.
Egs: Action name is TestAction.
Here only we will do the orginal coding .Get the form value , database manipulation etc…
Finally after complete the each and every file look up to the (strutconfig.xml) file.
Error will be occur the following situation:
1. Form name and Struts action form bean name are not match.
2. Form Action name and strut action name are not match.
3. Variable names and property names are not equal.
4. All package are properly not imported.(java and strut packages).
5. All taglib file are properly import into the designing file(*.jsp file)
6. Not proper entry for inside the strutconfig.xml file.
7. Iterate id name is equal to package Name. And In Iterate procedure bean write name is also equal to package name.
Remainig you will refer JDBC tutorial and struts tutorial.