jsp ms acess form

Reply

Join Date: Jul 2009
Posts: 4
Reputation: ankurmawanda is an unknown quantity at this point 
Solved Threads: 0
ankurmawanda ankurmawanda is offline Offline
Newbie Poster

jsp ms acess form

 
0
  #1
Jul 6th, 2009
i want to create a simple form which stores date in to a ms access db

so i created a form register.html and action user_register.jsp

i also created a ms aceess db

when i fill the form the data is passed to the Auction.mdb but the server shows error


HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /user_register.jsp:11

8: <% Statement myStatement = myConn.createStatement (); %>
9: <% String StrUser = request.getParameter("username"); %>
10: <% String StrPass = request.getParameter("password"); %>
11: <% ResultSet myResult = myStatement.executeQuery("INSERT INTO Auction([UserName], [Password]) VALUES ('"+StrUser+"', '"+StrPass+"')"); %>
12: <% myConn.close(); %>
13: </BODY>
14: </HTML>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

javax.servlet.ServletException: No ResultSet was produced
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.user_005fregister_jsp._jspService(user_005fregister_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.sql.SQLException: No ResultSet was produced
sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:259)
org.apache.jsp.user_005fregister_jsp._jspService(user_005fregister_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.







the regiser.html is




  1. <html>
  2. <head>
  3. <title>Welcome to the Action...</title></head>
  4. <body>
  5. <form action="user_register.jsp" method="post">
  6. Username:<input type="text" name="username">
  7. Password:<input type="password" name="password">
  8. <input type="submit" name="okfunc" value="OK">
  9. </form></body></html>

user_register.jsp is

  1. <HTML>
  2. <BODY>
  3. <%@ page language="java" import="java.sql.*" %>
  4. <% String url = "jdbc:odbc:Auction", user="", passwd=""; %>
  5. <% Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); %>
  6. <%--<% Connection myConn = DriverManager.getConnection (url, user, passwd); %> --%>
  7. <% Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb"); %>
  8. <% Statement myStatement = myConn.createStatement (); %>
  9. <% String StrUser = request.getParameter("username"); %>
  10. <% String StrPass = request.getParameter("password"); %>
  11. <% ResultSet myResult = myStatement.executeQuery("INSERT INTO Auction([UserName], [Password]) VALUES ('"+StrUser+"', '"+StrPass+"')"); %>
  12. <% myConn.close(); %>
  13. </BODY>
  14. </HTML>





i m very new to jsp so any help wud be gr8
thanx in advance
Last edited by peter_budo; Jul 6th, 2009 at 5:21 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,582
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 457
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: jsp ms acess form

 
0
  #2
Jul 6th, 2009
Welcome ankurmawanda,

Its difficult to read your source code. Use bb code tags to post source code. See # icon at toolbar and also read How to use bb code tags?.


[code=Jsp]
...
... your source code..
[/code]
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 4
Reputation: ankurmawanda is an unknown quantity at this point 
Solved Threads: 0
ankurmawanda ankurmawanda is offline Offline
Newbie Poster

Re: jsp ms acess form

 
0
  #3
Jul 6th, 2009
this is the server error log


HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /user_register.jsp:11

8: <% Statement myStatement = myConn.createStatement (); %>
9: <% String StrUser = request.getParameter("username"); %>
10: <% String StrPass = request.getParameter("password"); %>
11: <% ResultSet myResult = myStatement.executeQuery("INSERT INTO Auction([UserName], [Password]) VALUES ('"+StrUser+"', '"+StrPass+"')"); %>
12: <% myConn.close(); %>
13: </BODY>
14: </HTML>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

javax.servlet.ServletException: No ResultSet was produced
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.user_005fregister_jsp._jspService(user_005fregister_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.sql.SQLException: No ResultSet was produced
sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:259)
org.apache.jsp.user_005fregister_jsp._jspService(user_005fregister_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.


the register.html file

  1.  
  2. <html>
  3. <head>
  4. <title>Welcome to the Action...</title></head>
  5. <body>
  6. <form action="user_register.jsp" method="post">
  7. Username:<input type="text" name="username">
  8. Password:<input type="password" name="password">
  9. <input type="submit" name="okfunc" value="OK">
  10. </form></body></html>


the user_register.jsp

  1. <HTML>
  2. <BODY>
  3. <%@ page language="java" import="java.sql.*" %>
  4. <% String url = "jdbc:odbc:Auction", user="", passwd=""; %>
  5. <% Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); %>
  6. <%--<% Connection myConn = DriverManager.getConnection (url, user, passwd); %> --%>
  7. <% Connection myConn = DriverManager.getConnection("jdbc:odbcriver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb"); %>
  8. <% Statement myStatement = myConn.createStatement (); %>
  9. <% String StrUser = request.getParameter("username"); %>
  10. <% String StrPass = request.getParameter("password"); %>
  11. <% ResultSet myResult = myStatement.executeQuery("INSERT INTO Auction([UserName], [Password]) VALUES ('"+StrUser+"', '"+StrPass+"')"); %>
  12. <% myConn.close(); %>
  13. </BODY>
  14. </HTML>
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,582
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 457
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: jsp ms acess form

 
0
  #4
Jul 6th, 2009
Use single scriptlet if possible. To execute Non-query(Insert/delete/update/create/alter) use executeUpdate() method.

If the given connection url fails then use System DSN.
  1. <HTML>
  2. <BODY>
  3. <%@ page language="java" import="java.sql.*" %>
  4. <%
  5. String url = "jdbc:odbc:Auction", user="", passwd="";
  6. Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
  7. Connection myConn = DriverManager.getConnection("jdbc:odbcriver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
  8. Statement myStatement = myConn.createStatement ();
  9. String StrUser = request.getParameter("username");
  10. String StrPass = request.getParameter("password");
  11.  
  12. myStatement.executeUpdate("INSERT INTO Auction([UserName], [Password]) VALUES ('"+StrUser+"', '"+StrPass+"')");
  13. myStatement.close();
  14. myConn.close();
  15.  
  16. %>
  17. </BODY>
  18. </HTML>
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 4
Reputation: ankurmawanda is an unknown quantity at this point 
Solved Threads: 0
ankurmawanda ankurmawanda is offline Offline
Newbie Poster

Re: jsp ms acess form

 
0
  #5
Jul 6th, 2009
the value filled in the form are getting stored in the auction .mdb database but i still get a server error 500....

thanx in advance

thanku adatapost for ur reply
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,582
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 457
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: jsp ms acess form

 
0
  #6
Jul 6th, 2009
Error 500 shows that your page script has some problems. Let us know - How did you create your web application? - manually or netbean.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 4
Reputation: ankurmawanda is an unknown quantity at this point 
Solved Threads: 0
ankurmawanda ankurmawanda is offline Offline
Newbie Poster

Re: jsp ms acess form

 
0
  #7
Jul 6th, 2009
Originally Posted by adatapost View Post
Error 500 shows that your page script has some problems. Let us know - How did you create your web application? - manually or netbean.

i did it manually...............i am using tomcat apache 5.5.27

actually i googled the code
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,582
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 457
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: jsp ms acess form

 
0
  #8
Jul 6th, 2009
Do you know how to create a web context? Actually, first you have to create web-context. Do you know the structure of Web application?
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC