Step1: Creating New Project
a) Goto File->New Project ( One window will open)
b) In Project Window , Select Web -> Web Application
c) Select Next
d) Enter the Name of the Project [Eg. MyServlet] and path
e) Select Next
f) Select the J2EE version and Server which you want to
deploy the web Application
[Eg : J2EE5 and Tomcat 6.1]
a) Goto File->New Project ( One window will open)
b) In Project Window , Select Web -> Web Application
c) Select Next
d) Enter the Name of the Project [Eg. MyServlet] and path
e) Select Next
f) Select the J2EE version and Server which you want to
deploy the web Application
[Eg : J2EE5 and Tomcat 6.1]
g) Finish the wizard.
Format of Servlet Project
MyServlet (Project Name)
|
|_Web Pages (create html,jsp files here)
|
|-Configuration Files (configure web.xml file)
|
|-Server Resources
|
|-Source Package (create java servlet here)
|
|_Test packages
|
|-Libraries (Add external jar file here)
|
|-Test Libraries
|
|_Web Pages (create html,jsp files here)
|
|-Configuration Files (configure web.xml file)
|
|-Server Resources
|
|-Source Package (create java servlet here)
|
|_Test packages
|
|-Libraries (Add external jar file here)
|
|-Test Libraries
Step 2 : Creating JSP or HTML file
a) Right click on the Web Pages Folder
b) Select New -> HTML option from the pop up window.
c) Type the name of your html page.
d) Finish the wizard.
a) Right click on the Web Pages Folder
b) Select New -> HTML option from the pop up window.
c) Type the name of your html page.
d) Finish the wizard.
Eg. select.html
<form action="SelectDetails" method="get">Select the Branch
<select name="branch">
<option value="IT"> B.Tech - IT </option>
<option value="CSE"> B.Tech - CSE </option>
<option value="ECE"> B.Tech - ECE </option>
<option value="MECH"> B.Tech - Mech </option>
</select>
<input type="submit" value="GetDetails" />
</form>
Step 3: MySQL Database : Check Table Name : student
id name branch
1 Amar IT
2 Amit CSE
3 Antony MECH
4 Anbu ECE
103 Sree MECH
102 Karthick IT
104 Deepan ECE
105 Moorthy CSE
id name branch
1 Amar IT
2 Amit CSE
3 Antony MECH
4 Anbu ECE
103 Sree MECH
102 Karthick IT
104 Deepan ECE
105 Moorthy CSE
Step 4: Add MySQL Jconnector jar file under “Libraries” foleder
Libraries -> Right Click -> Select Add New Jar File / Folder
My Path : /media/Backup/mysql-connector-java-5.1.6-bin.jar
Libraries -> Right Click -> Select Add New Jar File / Folder
My Path : /media/Backup/mysql-connector-java-5.1.6-bin.jar
Step 5: Creating Servlet
a) Right click on the Source Package Folder
b) Select New -> Servlet option from the pop up window.
c) Type the name of your html page.
d) Finish the wizard.
a) Right click on the Source Package Folder
b) Select New -> Servlet option from the pop up window.
c) Type the name of your html page.
d) Finish the wizard.
Eg:SelectDetails.java
Step 4 : Run the project.
URL => http://localhost:8084/MyServlet/select.html
URL => http://localhost:8084/MyServlet/select.html
Output for CSE
id = 2, name = Amit
id = 105, name = Moorthy
id = 2, name = Amit
id = 105, name = Moorthy
No comments:
Post a Comment