Question: Programming error

Ads

 
 
 

Share on Google+Share on Google+

Harshu
Programming error
0 Answer(s)      7 years ago
Posted in : JSP-Servlet
Register.jsp

<%@ page language="java" import="java.io.*,java.lang.*,java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>


<%

Connection con=null;
ResultSet rs=null;
Statement stmt=null;
int Urid=0;

String strDateNew=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Advdsn");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
java.util.Date now = new java.util.Date();
String DATE_FORMAT = "dd-MM-yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
strDateNew = sdf.format(now) ;

ResultSet uid=stmt.executeQuery("select UserId from Register1");

while(uid.next())
{
int user=uid.getInt("UserId");
Urid=user+1;
}


}



catch(SQLException se)
{out.println("Database error="+se.getMessage());
}

catch(Exception e)
{out.println("Error="+e.getMessage());
}


%>




<HTML>
<HEAD>
<TITLE> Registration Form</TITLE>


<script type="text/javascript">
function checkName(text)
{
if(isNaN(text)){ return 1;}
else{alert("Invalid Name! The only charachters accepted are A - Z and a - z");return 0;}
}
function checkPhoneNo(num){
if(isNaN(num)){alert("Invalid Phone Number. The only characters permitted are 0 to 9"); return 0;}
else{return 1;}
}

function validate()
{
var name=document.form.Name;
var phone=document.form.PhoneNo;
var email=document.form.Email;
var desig=document.form.Desig;
var add=document.form.Address;
var contact=document.form.Contact;

if(name.value=="")
{ alert("Please enter valid Client's Name");
return false;

}
if(add.value=="")
{ alert("Please enter valid Address");
return false;
}
if(contact.value=="")
{ alert("Please enter valid Client's Name");
return false;

}
if (checkName(name.value)==false){
name.value="";
name.focus();
return false;
}
if(document.form.Address.value=="")
{ alert("Please enter valid Client's Address");
return false;
}

if(desig.value=="")
{ alert("Please enter valid Designation");
return false;

}

if(email.value=="")
{ alert("Please enter valid Email Id");
return false;
}
apos=email.value.indexOf("@")
dotpos=email.value.lastIndexOf(".")
if (apos<1 || dotpos-apos<2)
{
alert("Invalid Email Id")
email.value=="";
email.focus();
return false;
}

if((phone.value=="")||(phone.value==null))
{ alert("Please enter valid PhoneNo");phone.focus();
return false;
}
if (checkPhoneNo(phone.value)==false){
phone.value="";
phone.focus();
return false;
}
if ((phone.value.length==8)||(phone.value.length==10)){
return true;
}
else{
alert("Phone Number must be of 8 numbers or 10 numbers");
return false;
}
return true;
}

</script>


</HEAD>

<BODY BGCOLOR="lightblue">
<marquee behavior="alternate" scrollamount=5 scrolldelay=10>
<h1><font size=4 face="Stroustroup" color="#993355">Advertisement Management System</h1></font></marquee><br>
<p align=center>Registration Form</p>
<hr color="green">
<img src="images\working with agency.jpg" alt"ORDERS" align="left"></img>
<form method="post" name="form" onsubmit="return validate();" action="http://localhost:8080/ProjectAd/Registration.jsp">
<center>
<table>
<tr><td>User ID:</td><td><input type="text" id="Userid" name="Userid" size=25 value="<%=Urid%>" readonly></td></tr>
<tr><td>Name:</td><td><input type=text name="Name" size=25 ></td></tr>
<tr><td>Registration Date:</td><td><input type=text name="Date" value="<%=strDateNew%>" readonly size=25></td></tr>
<td>Address:</td><td><textarea name="Address" rows=5 cols=22 size=25></textarea></td></tr>
<tr><td>Designation:</td><td><input type=text name="Desig" size=25 ></td></tr>

<tr><td>Email:</td><td><input type=text name="Email" size=25></td></tr>
<tr><td>PhoneNo:</td><td><input type=text name="PhoneNo" size=25 maxlength=10></td></tr>
<tr><td>Contact Details:</td><td><input type=text name="Contact" size=25 ></td></tr>

<tr><td><input type=submit name=submit value="Register"></td>
<td><input type=reset name=reset value="Reset"></td></tr>
</table>
</center>

</form>
<p align=center><a href="http://localhost:8080/ProjectAd/Main.html"><img src="images/home_ap.jpg" height=20 width=20></a>
<p align=bottom><a href="http://localhost:8080/ProjectAd/HelpRegister.html">Help</a></p>
<hr color="green">
</BODY>
</HTML>

Hello Sir,

Registration.jsp

<[email protected] import ="java.io.*" %>
<[email protected] import ="java.sql.*" %>
<[email protected] import= "java.util.*" %>
<[email protected] import ="java.text.*" %>
<[email protected] import="java.text.SimpleDateFormat" %>

<%
String id=request.getParameter("Userid");
String name=request.getParameter("Name");
String address=request.getParameter("Address");
String email=request.getParameter("Email");
String phoneno=request.getParameter("PhoneNo");
String desig=request.getParameter("Desig");
String day=request.getParameter("Date");
String contact=request.getParameter("Contact");

%>
<html>
<body bgcolor="#D0D0D0">
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:Advdsn");
PreparedStatement ps=con.prepareStatement("insert into Register1 values(?,?,?,?,?,?,?,?)");
ps.setInt(1,Integer.parseInt(id));
ps.setString(2,name);
ps.setString(3,day);
ps.setString(4,address);
ps.setString(5,desig);
ps.setString(6,email);
ps.setString(7,phoneno);
ps.setString(8,contact);
int x=ps.executeUpdate();
if(x>0)
out.println("You have been Registered now you can place Order");
else
response.sendRedirect("Registers.jsp");
}
catch(SQLException se)
{
out.println("Database Error :"+se.getMessage());
}
catch(Exception e)
{
out.println("General Error :"+e.getMessage());
}

%>
<form name="form" action="PlaceOrd.jsp">
<input type=submit name=submit value="PlaceOrder">
<input type="hidden" name=u value=<%=id%>">
</form>
</body>
</html>

Place Order.jsp
<%@ page language="java" import="java.io.*,java.lang.* ,java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>


<%

Connection con=null;
ResultSet rs=null;
Statement stmt=null;
int No=0;int uid=0;
String user=null;
String strDateNew=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Advdsn");
stmt=con.createStatement();
java.util.Date now = new java.util.Date();
String DATE_FORMAT = "dd-MM-yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
strDateNew = sdf.format(now) ;

ResultSet no=stmt.executeQuery("select OrderNo from OrderTab");

while(no.next())
{
int Ono=no.getInt("OrderNo");
No=Ono+1;
}


}



catch(SQLException se)
{out.println("Database error="+se.getMessage());
}

catch(Exception e)
{out.println("Error="+e.getMessage());
}


%>
<% String u1=request.getParameter("u"); %>

<HTML>
<HEAD>
<TITLE> Place Order </TITLE>
</HEAD>

<BODY BGCOLOR="lightblue">
<marquee behavior="alternate" scrollamount=5 scrolldelay=10>
<h1><font size=4 face="Stroustroup" color="#993355">Advertisement Management System</h1></font></marquee><br>
<p align=center> Order Details</p>
<hr color="green">
<img src="images\working with agency.jpg" alt"ORDERS" align="left"></img>

<form method="post" name="form" action="http://localhost:8080/ProjectAd/Orders.jsp">
<center>
<table>
<tr><td>Order No:</td><td><input type="text" id="OrderNo" name="OrderNo" size=25 value="<%=No%>" readonly ></td></tr>
<tr><td>Order Date:</td><td><input type=text name="Date" value="<%=strDateNew%>" size=25 readonly></td></tr>

<tr><td>Name:</td><td><select name="Name" size=1 >
<%
ResultSet nm=stmt.executeQuery("Select Name from Register1 ");
while(nm.next())
{
user=nm.getString("Name");
%>
<option value="<%=user%>">
<%

out.println(user); %>
</option>
<%}%>
</select></td></tr>
ResultSet id=stmt.executeQuery("Select userid from Register1 where name='<%=user%>'");
while(id.next())
{
int uid=id.getInt("Userid");
%>
<tr><td><input type=text name=Userid value=<%=user%> size=25></td></tr>
<%}%>

</center>
</table>
<input type="hidden" name=uuid value="<%=u1%>">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit name=submit value="InsertOrder">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=reset name=reset value="Reset">


</form>
<p align=center><a href="http://localhost:8080/ProjectAd/Main.html"><img src="images/home_ap.jpg" height=20 width=20></a>
<p align=bottom><a href="http://localhost:8080/ProjectAd/HelpOrder.html">Help</a></p>
<hr color="green">
</BODY>
</HTML>

Hello Sir in this Place Order Page i want that when user select a name from the Name combobox that comes from registration form then its corresponding userid from the datebase must get diplayed in Userid textbox .
How to do this sir i tried its taking value from the combo box but when i write a query to match whether name from database is matching the name selected from combobox and to get its corresponding id but its giving me error.
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
programming error
programming error  I got an error when i did the following program the prg. is to "select the name from database when the age is given for the respective name" error i got is:SQL exception please give me the solution by providing
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
Advertisements
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
error at programming
error at programming  import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*; public class Login extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res
error at programming
error at programming  <p>import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.sql.*;</p> <p>public class Login extends HttpServlet { public void doPost(HttpServletRequest
Programming Error - JSP-Servlet
Programming Error  Hello Sir, how to convert a txt written in textarea of html must get converted to integers and should get displayed... integer.parseInt but its giving error. Please Reply me . Thank you
Programming Error - JSP-Servlet
Programming Error   Place Ad function funct(){ if(document.form.DraftAd.value=="" || document.form.DraftAd.value==null... ??? And when i tried its giving me error than cannot find variable.In
Programming Error - JSP-Servlet
Programming Error  Hello Sir, import java.util.*; import...(); } } }//End of class m geeting error in this can u please tell me whats the error nd how to solve
Programming error - JDBC
Programming error  import javax.servlet.*; import...) { out.println("Database Error :"+se.getMessage()); } catch(Exception e) { out.println(e.toString()); } } } Please reply me the error in this program because i
Programming Error - JSP-Servlet
Programming Error   Place Order function checkName...(""); } catch(SQLException se) { out.println("Database Error :"+se.getMessage()); } catch(Exception e) { out.println("General Error :"+e.getMessage
Programming error - JSP-Servlet
Programming error  Register.jsp Registration..."); } catch(SQLException se) { out.println("Database Error :"+se.getMessage()); } catch(Exception e) { out.println("General Error :"+e.getMessage()); } %>
Programming error - JSP-Servlet
Programming error  Actually there is an error in placeorder.jsp file where there are 5 fields OrderNo ,Name , Address, Email, PhoneNo where if I delete an order of client based on orderno then suppose in database if there are 5
Programming error - JSP-Servlet
Programming error   --%> Place Order function Validate() { var valid=true; if(document.forms.OrderNo.value=="") { alert... where if @ is not given or (dot). is not given etc then it should display error
programming error - Java Beginners
programming error  What is error in this page and how to use RequestDispatcher in servlet to validate it please do reply?? import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; import
programming error - Java Beginners
programming error  import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class Place_Ad extends...) { out.println("Database Error :"+se.getMessage()); } catch(Exception e
programming error - Java Beginners
programming error  how can we statically implement linked list????????  Hi Friend, Please visit the following links: http://www.roseindia.net/java/jdk6/LinkedListExample.shtml http://www.roseindia.net/java
Programming Error - JSP-Servlet
Programming Error  Image: I want that when user clicks on browse button then a folder of images should get open and when user clicks one image from it (only one not more than that)then it should get displayed on next page
Programming error - JSP-Servlet
Programming error  Hello Sir, Can u please reply me the code for javamail please actually i watch the javamail.net but i dint understood it. Actually i want to send a mail to my clients with a small text message. Please
Programming Error - JSP-Servlet
Programming Error  Image: Browse When user clicks on Browse Button then a folder of images should get open and when user clicks one of them then the path of that should get saved in Access Database and on next page
Programming Error - JSP-Servlet
Programming Error   Payment Advertisement Management System Payment Premium Position FrontPage BackPage Other Premium Pages Page 2 Page 3 Page 5 Page 7 Total Cost: How to use switch
Programming Error - JSP-Servlet
Programming Error   Place Ad function funct(){ if(document.form.DraftAd.value=="" || document.form.DraftAd.value==null) { document.form.cnt.value=0;} else {document.form.cnt.value
Programming Error - JSP-Servlet
Programming Error  How to validate login page using jsp where it checks for username whether it is empty or not or is it including number or not if it is the paste alert message.   Hi Friend, Try the following
Programming Error - JSP-Servlet
Programming Error   function Draft() { if(document.form.Count.value==""||document.form.Count.value==null) document.form.Count.value=0; else document.form.Count.value = document.form.DraftAd.value.split(' ').length
Programming error - JSP-Servlet
Programming error   Payment Advertisement Management System Payment Premium Position FrontPage BackPage Other Premium Pages Page 2 Page 3 Page 5 Page 7 Total Cost: I want that the no of characters
Programming Error - JSP-Servlet
Programming Error  Ya States and cities and maincategory and subcategory are combobox and maincategory contains suppose matrimonial then sub category will contain groom and bride, if main category contains vehicals then sub
Programming Error - JSP-Servlet
Programming Error   Place Ad Advertisement Management System Create Ad State: City: Main Category: Sub Category: Title: Draft Your Ad Here
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads