Steps to create a Dynamic Web Application and connect to ...

18
Steps to create a Dynamic Web Application and connect to MS SQLSERVER to get the data and display in a web page Using ECLIPSE with JDBC ODBC Bridge: 1) Click on New -> Other 2) Type Dynamic, and select “Dynamic Web Project” and click on Next (if you don’t find Dynamic Web Project, install using Click "Help" > "Install new software. Please find steps to get ‘Dynamic Web Project’ in menu at end of this document)

Transcript of Steps to create a Dynamic Web Application and connect to ...

Steps to create a Dynamic Web Application and connect to MS SQLSERVER to

get the data and display in a web page Using ECLIPSE with JDBC ODBC Bridge:

1) Click on New -> Other

2) Type Dynamic, and select “Dynamic Web Project” and click on Next

(if you don’t find Dynamic Web Project, install using Click "Help" > "Install new software.

Please find steps to get ‘Dynamic Web Project’ in menu at end of this document)

3) Give Project name and click next

4) Click on Next Button

5) Click on Finish. Now the project has been created

Second Phase: Import the required jar’s

1) Right click on the project and click on Properties

2) Import jstl.jar, servlet-api.jar and stardard.jar files into build path.

( Please find the attached jar files with this document)

3) Add the jar files under WebContent->lib folder

Create a JSP Page: index.jsp

Right click on WebContent folder ->New -> JSP File

Step1:

Step 2:

Import jstl library in index.jsp page:

Create a Servlet Page :

step 1: Create a servlet file by right click on src -> New -> Servlet

Step 2:

Running the web application using apache tomcat server:

1) Right click on the project, Click on Run As -> Run on Server

1) Select tomcat server and click on next.

(if you don’t have tomcat server installed, you can download from here)

2) Click on browse and select the Apache Tomcat folder

3) And click on finish.

4) Type ‘localhost:8080/YOUR_PROJECT_NAME/’ in any web browser, your application will

start.

When you Click on ‘Get Employee Details’ Button:

The application will hit the database through java servlet and display the results in jsp page:

The following code is responsible for fetching data from database:

In the above code “Company_DSN” is the domain server name configured to establish

connection between application and ms sqlserver database:

Please follow the steps to create domain server name and use in the java code

1) Click on Administrative Tools

2) Click on Data Sources (ODBC)

3) Click on Add button

4) Select SQL Server and click on Finish

5) Enter Data source Name and Server Name.

To find the server name do the following

6) Click on Next Button

7) Select Check box, Select your database using the dropdown, and click ‘Next’ Button

8) Click on ‘Next’ Button

9) Click on ‘Test Data Source’ Button to test the connection

10) It will show ‘Tests Completed Successfully’. Then Click ok. You are connection to

SQLSERVER has been established now.

Steps to get Dynamic Web Application to the menu list:

1. Click "Help" > "Install new software"

2. In "Work with", Select the dropdown

3. In "Web, XML, Java EE and OSGi Enterprise Development", check:

1. Eclipse Java EE Developer Tools

2. Eclipse Java Web Developer Tools

3. Eclipse Web Developer Tools

4. Eclipse XML Editors and Tools

4. Finally, click "Next" to install the new software and "Dynamic Web Project" will be

available.