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...

Page 1: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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)

Page 2: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

3) Give Project name and click next

4) Click on Next Button

Page 3: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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

Page 4: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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

( Please find the attached jar files with this document)

Page 5: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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

Create a JSP Page: index.jsp

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

Step1:

Page 6: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

Step 2:

Import jstl library in index.jsp page:

Page 7: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

Create a Servlet Page :

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

Step 2:

Page 8: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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)

Page 9: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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.

Page 10: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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:

Page 11: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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)

Page 12: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

3) Click on Add button

4) Select SQL Server and click on Finish

Page 13: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

5) Enter Data source Name and Server Name.

To find the server name do the following

Page 14: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

6) Click on Next Button

Page 15: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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

8) Click on ‘Next’ Button

Page 16: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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.

Page 17: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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

Page 18: Steps to create a Dynamic Web Application and connect to ...cis.csuohio.edu/.../StepsToSetUpWebApplicationJDBC_ODBC_MSSQ… · Steps to create a Dynamic Web Application and connect

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

available.