Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem accessing Oracle database through JDBC using JSP

 
Vicky Johnny
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Am relatively new to JSP. Am trying to access a oracle DB through JDBC using JSP.

1. I have created a database EmployeeDB with columns emplname, empid, salary, location etc.

2. Next, I have tomcat installed.

3. I created a directory called "Root" in c:\ The Root directory has another sub-directory "WEB-INF" and employ2.jsp.

c:\root
/ \
employ2.jsp WEB-INF
/ \ \
lib classes web.xml


4. The WEB-INF has 2 more sub-folders "classes" and "lib" and a file "web.xml"

5. The employ2.jsp loads the JDBC driver, connects it to the EmployeeDB database and executes the query "select * from EMPLOYEEDB"

6. Then I wrote a basic web.xml which mentions the welcome-file as "employ2.jsp"

7. After that I start Tomcat server using startup.bat in command prompt.

8. Then I create a emp.war file in c:\root using jar cvf command i.e jar cvf c:\root\emp.war -c c:\root

9. Now I copy the emp.war file in the webapps folder of tomcat directory

10. After that I go to browser and type in http://localhost:8181/emp

Here, I get a Http 404 error.

Can somebody point out where am wrong.

Thank you.
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its hard to guess what the problem is. Can you go to tomcat manager (http://localhost:8181/manager/html) to see if your application was deployed successfully (I'm assuming your tomcat is running on port 8181). There might be some problem with your web.xml or something else. Also did you define welcome-file-list in your web.xml?? If you didn't, then you might want to try the URL http://localhost:8181/emp/employ2.jsp in your browser...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64609
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vicky Johnny wrote:Am relatively new to JSP.

Then you should start out on the right foot and learn good habits ansd best practices right off the bat.

And one of the biggest is to never, ever, ever, ever and did I mention ever, mix database code in with UI code. Never.

Did I menton never?

That said, it doesn't sound like your question has anything to do with databases, but with just getting a web app up and running.

I've moved this topic to the Tomcat forum for any further discussion.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64609
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Port 8181? Why?
 
Vicky Johnny
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Port 8181? Why?


The default 8080 port is conflicting with Oracle, so I modified the port number in server.xml in tomcat's confluence folder... Thanks
 
Vicky Johnny
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:Its hard to guess what the problem is. Can you go to tomcat manager (http://localhost:8181/manager/html) to see if your application was deployed successfully (I'm assuming your tomcat is running on port 8181). There might be some problem with your web.xml or something else. Also did you define welcome-file-list in your web.xml?? If you didn't, then you might want to try the URL http://localhost:8181/emp/employ2.jsp in your browser...


Yes my web.xml is very basic.

 
Vicky Johnny
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:Its hard to guess what the problem is. Can you go to tomcat manager (http://localhost:8181/manager/html) to see if your application was deployed successfully (I'm assuming your tomcat is running on port 8181). There might be some problem with your web.xml or something else. Also did you define welcome-file-list in your web.xml?? If you didn't, then you might want to try the URL http://localhost:8181/emp/employ2.jsp in your browser...


Hi,

Yes the emp.war file has been deployed successfully. I can see application running (=True)... however when I type http://localhost:8181/emp, I get the HTTP 404 requested resource not available...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic