| Author |
Problem accessing Oracle database through JDBC using JSP
|
Vicky Johnny
Greenhorn
Joined: Oct 27, 2009
Posts: 11
|
|
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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
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...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56209
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56209
|
|
|
Port 8181? Why?
|
 |
Vicky Johnny
Greenhorn
Joined: Oct 27, 2009
Posts: 11
|
|
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
Joined: Oct 27, 2009
Posts: 11
|
|
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
Joined: Oct 27, 2009
Posts: 11
|
|
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...
|
 |
 |
|
|
subject: Problem accessing Oracle database through JDBC using JSP
|
|
|