Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

jsp insert program not working

 
Greenhorn
Posts: 7
Tomcat Server Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Heyya programmers!
i've project work to complete , by short amount of time and the add program is not working! i've attached a sanpshort if the error
And here is the code. By the way the view and delete programs are working superbly, so there is no error on Dsn connection.
And i had crossed checked it, i made sure that there are not blank spaces on the add program :(

HELLLPPPPPPPPPPP please.,,,!!!

Jsp
---------------------------------------------------------
<%@page import="java.sql.*"%>
<%@page import="repeat.dbconnect"%>
<jsp:useBean id="a" class="repeat.dbconnect"/>
<jsp:getProperty name="a" property="conn"/>
<%String S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,S16,S17;
S1=request.getParameter("T1");
S2=request.getParameter("T2");
S3=request.getParameter("T3");
S4=request.getParameter("T4");
S5=request.getParameter("T5");
S6=request.getParameter("T6");
S7=request.getParameter("T7");
S8=request.getParameter("T8");
S9=request.getParameter("T9");
S10=request.getParameter("T10");
S11=request.getParameter("T11");
S12=request.getParameter("T12");
S13=request.getParameter("T13");
S14=request.getParameter("T14");
S15=request.getParameter("T15");
S16=request.getParameter("T16");
S17=request.getParameter("T17");
int c=Integer.parseInt(S1);
int b=Integer.parseInt(S15);
int k=a.stmt.executeUpdate("insert into Form values("+c+",'"+S2+"','"+S3+"','"+S4+"','"+S5+"','"+S6+"','"+S7+"','"+S8+"','"+S9+"','"+S10+"','"+S11+"','"+S12+"','"+S13+"','"+S14+"',"+b+",'"+S16+"','"+S17+"',)");
%>
<script> alert("Record is inserted");
document.location="../Web/Add.html"
</script>


Html
-----------------------------------------------------------
<html>

<head>
<title>Registration for New Student</title>
</head>

<body>

<table border="1" width="100%">
<tr>
<td colspan="2" height="38">
<p align="center"><b><font size="5">Registration for New Student in
Hostel</font></b></td>
</tr>
<tr>
<td width="35%">Candidate's ID.</td>
<td width="63%"><input type="text" name="T1" size="10"></td>
</tr>
<tr>
<td width="35%">Candidate's Name.</td>
<td width="63%"><input type="text" name="T2" size="33"></td>
</tr>
</table>
<table border="1" width="100%">
<tr>
<td width="35%">Father's Name.</td>
<td width="63%"><input type="text" name="T3" size="33"></td>
</tr>
</table>
<table border="1" width="100%">
<tr>
<td width="35%">Address.</td>
<td width="63%"><textarea rows="4" name="T4" cols="28"></textarea></td>
</tr>
</table>
<table border="1" width="100%">
<tr>
<td width="35%">Parent/Guardian Phone no.</td>
<td width="63%"><input type="text" name="T5" size="20"></td>
</tr>
</table>
<table border="1" width="100%">
<tr>
<td width="35%">Parent/Guardian Mobile no.</td>
<td width="63%"><input type="text" name="T6" size="20"></td>
</tr>
<tr>
<td width="35%">Parent/Guardian Email id (if any).</td>
<td width="63%"><input type="text" name="T7" size="34"></td>
</tr>
</table>
<table border="1" width="100%">
<tr>
<td width="35%">Student Mobile no.</td>
<td width="63%"><input type="text" name="T8" size="20"></td>
</tr>
</table>
<table border="1" width="100%">
<tr>
<td width="35%">Student Email id.</td>
<td width="63%"><input type="text" name="T9" size="34"></td>
</tr>
<tr>
<td width="35%">Blood Group.</td>
<td width="63%"><input type="text" name="T10" size="3"></td>
</tr>
<tr>
<td width="35%">Present illness if any.</td>
<td width="63%"><input type="text" name="T11" size="34"></td>
</tr>
<tr>
<td width="35%">Local Address of Guardian (if any).</td>
<td width="63%"><textarea rows="4" name="T12" cols="28"></textarea></td>
</tr>
<tr>
<td width="35%">Caste.</td>
<td width="63%"><input type="text" name="T13" size="3"></td>
</tr>
<tr>
<td width="35%" height="25">Class in which Studying and the Branch</td>
<td width="63%" height="25"><input type="text" name="T14" size="34"></td>
</tr>
<tr>
<td width="99%" colspan="2">Stays in Room No. With the following
Roommates.</td>
</tr>
<tr>
<td width="35%" height="25">Room No.</td>
<td width="63%" height="25"><input type="text" name="T15" size="4"></td>
</tr>
<tr>
<td width="35%">1)</td>
<td width="63%"><input type="text" name="T16" size="33"></td>
</tr>
<tr>
<td width="35%">2)</td>
<td width="63%"><input type="text" name="T17" size="33"></td>
</tr>
</table>
<form method="POST" action="../Src/Add.jsp">

<p> <input type="submit" value="Submit" name="B1">        
<input type="reset" value="Reset" name="B2">        
</p>
</form>
<form method="POST" action="../Web/Admin.html">
<p><input type="submit" value="Return" name="B3"></p>
</form>

</body>

</html>
untitled.JPG
[Thumbnail for untitled.JPG]
 
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either S1 or S15 is null. Make sure all your parameter names are correct, both in the form and in your JSP page.

That said, there are two other issues here:
1) Your code does not protect against SQL injection. You should use a PreparedStatement instead.
2) You shouldn't add Java code to JSPs anymore. Instead, use a servlet as the form action to perform the processing, then let it redirect to a JSP for displaying the results.
 
Tuhin Bagh
Greenhorn
Posts: 7
Tomcat Server Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Either S1 or S15 is null. Make sure all your parameter names are correct, both in the form and in your JSP page.

That said, there are two other issues here:
1) Your code does not protect against SQL injection. You should use a PreparedStatement instead.
2) You shouldn't add Java code to JSPs anymore. Instead, use a servlet as the form action to perform the processing, then let it redirect to a JSP for displaying the results.



Shall i give you my, project stuff?
just copy it in Roots folder of your tomcat!
just i had crossed checked again :( can't find any error. Earlier it was working, donno what happen!
 
Rob Spoor
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't need your entire project. You only need to show the form that's submitting these values. Or, if you don't use a form, how you're invoking this JSP page instead.
 
Tuhin Bagh
Greenhorn
Posts: 7
Tomcat Server Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:I don't need your entire project. You only need to show the form that's submitting these values. Or, if you don't use a form, how you're invoking this JSP page instead.


Frist thing first, i had created a system DSN same name as my .accdb name!
and i'm invoking the .jsp file via button on html . i had posted the html page code, :O i can't understand where is the problem!
Shall i write the whole code again..?? What you think Sir Rob
untitled.JPG
[Thumbnail for untitled.JPG]
 
Rob Spoor
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your input fields are located outside your form. Only fields within the form are submitted. Move your form opening tag to before the table.
 
Tuhin Bagh
Greenhorn
Posts: 7
Tomcat Server Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Your input fields are located outside your form. Only fields within the form are submitted. Move your form opening tag to before the table.


OMG!!! how did that silly mistake happened! I feel so noob.
The program worked like a charm :D Thanks a ton Rob :D are you on Facebook or some stuff btw..?? I needs your help, thought my college project is 50% completed..!!
next problem which m facing is a simple login authentication, shall i post here, or shall i post as a new topic..??
 
Rob Spoor
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tuhin Bagh wrote:

Rob Spoor wrote:Your input fields are located outside your form. Only fields within the form are submitted. Move your form opening tag to before the table.


OMG!!! how did that silly mistake happened! I feel so noob.
The program worked like a charm :D Thanks a ton Rob :D


You're welcome :)

are you on Facebook or some stuff btw..?? I needs your help, thought my college project is 50% completed..!!
next problem which m facing is a simple login authentication, shall i post here, or shall i post as a new topic..??


I am on Facebook but I only befriend people I know in real life. Please post your problems here, that way you can get help from more people.
As the login issue is a different problem, please create a new topic for it.
 
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic