Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC Displaying Date in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Deebapriya
Displaying Date in jsp
2 Answer(s)      6 years and 7 months ago
Posted in : JDBC



Advertisement
View Answers

June 14, 2008 at 7:39 PM


Hi

form

<html>
<title>Insert into database</title>
<head>

<script type="text/javascript">

function validateForm(theForm){



if(theForm.userid.value==""){

//Please enter username

alert("Please enter User Name!");

theForm.userid.focus();

return false;

}
if(theForm.address.value==""){
//please enter passward
alert("Please enter Address!");
theForm.address.focus();
return false;
}

if(theForm.dob.value==""){
//please enter passward
alert("Please enter Date of birth!");
theForm.dob.focus();
return false;
}


return true;
}
</script>
</head>

<body>

<table border="1" width="50%" bgcolor="pink">
<tr>
<td width="100%">
<form method="POST" action="DateInsertAction.jsp" onsubmit="return validateForm(this);">

<h2 align="center">Insert Date into Database</h2>
<table border="1" width="100%">
<tr>
<td width="50%"><b>User Name:</b></td>
<td width="50%"><input type="text" name="userid" size="20"/> </td>
</tr>
<tr>
<td width="50%"><b>Address:</b></td>
<td width="50%"><input type="test" name="address" size="50"/> </td>
</tr>
<tr>
<td width="50%"><b>Date of Birth:</b></td>
<td width="50%"><input type="test" name="dob" size="20"/> </td>
</tr>
</table>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>

</form>
</td>
</tr>
</table>

</body>

</html>


June 14, 2008 at 7:41 PM


insert action

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

<%
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";
java.util.Date date;
String s=null;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String userid=request.getParameter("userid");
String address=request.getParameter("address");
DateFormat dformat = new SimpleDateFormat("dd-MM-yyyy");

try{
date = new java.util.Date();
s = dformat.format(date);
System.out.println("Today = " + s);
}
catch(Exception e){
e.getMessage();
}
int val = st.executeUpdate("insert userInform values('"+userid+"','"+address+"','"+s+"')");
con.close();
out.println("Successfully insert Date into database.");
out.println("<br/><a href=dateForm.jsp><b>Back to Register Form</b></a>");
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>

-----------------------------------------

Read for more information.

http://www.roseindia.net/jsp/

Thanks

Amardeep)


Related Tutorials/Questions & Answers:
Displaying Date in jsp - JDBC
Displaying Date in jsp  I want to insert Date of birth of a person in a database.i am getting input value from HTML and i use jsp application to interact with database.My JSP code for inserting Date is below: String dateStr
Displaying date in the preciding code
Displaying date in the preciding code  while deploying the Bill date field on this page are empty though it should be displayed String userName = request.getParmeter("userName"); String custId = request.getParameter("customerId
Advertisements
Displaying files on selection of date.
Displaying files on selection of date.  Hi, I am developing a GUI, where i select from and to date. On selection of from and to date the GUI should show the particular txt files of the selected date. I want the java logic
Displaying image using jsp and spring.
Displaying image using jsp and spring.  how to display an image stored in WEB-INF/images folder on the browser using jsp and spring
Displaying Rows - JSP-Servlet
Displaying Rows  Hi, I need your support on how to display data from ms sql 2000 database into an html form text box and text area, using java servlet or jsp  Hi friend, This is form code, display data
Uploading a software and displaying it on the jsp page
Uploading a software and displaying it on the jsp page  I have a Downloads page in my website, I want it to display the name of softwares as soon as it is uploaded in the backend by the administrator. And the admin may be a non
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position...'><div class='divCellDT'>DATE/TIME</div>
Displaying java.util.Calendar using JSP struts tags
Displaying java.util.Calendar using JSP struts tags  My question is in regard to displaying a date whose source is java.util.Calendar... and display it as <s:date name="todayDate" format="yyyy-MM-dd" />
Data displaying with limited records in jsp
Data displaying with limited records in jsp  How to display table with limited 10 records , after clicking next button another 10 records from database upto last record please help me
displaying data retrieved from a database in a jsp page
displaying data retrieved from a database in a jsp page  the page...()) { Date date = rs.getDate(3); dateStr = DateFormat.getDateInstance(DateFormat.MEDIUM).format(date); } conn.close(); } catch (SQLException e
displaying long size arrow line in a jsp
displaying long size arrow line in a jsp  Hi all, How can we display an arrow mark with a specified height and width in a jsp. Please help me in resolving this problem. Thanks, Suresh
Retrieving newly inserted records and displaying in jsp forever
Retrieving newly inserted records and displaying in jsp forever  Sir... a table and display in jsp(Each row contains a field called as "session... of every record which is displayed on the jsp (not in database) and immediately i have
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them-in-text-fields-of-html-code.html http://www.roseindia.net/answers/viewqa/JSP
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them-in-text-fields-of-html-code.html http://www.roseindia.net/answers/viewqa/JSP
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them-in-text-fields-of-html-code.html http://www.roseindia.net/answers/viewqa/JSP
displaying employee records and their images problem - JSP-Servlet
displaying employee records and their images problem  hi, Thanks for your reply to my question. The code you sent to me yesterday was not working. it doesn't display any record and image. Please, help me out urgent
JFree 3D Bar Chart not displaying in JSP - Java3D
JFree 3D Bar Chart not displaying in JSP  Hi I am trying to run JFree 3D bar chart written in your site under link: http://www.roseindia.net/chartgraphs/3Dbarchart-in-jsppage.shtml This is not working. PNG file
Date Scheduler - JSP-Servlet
Date Scheduler  How to schedule a date in jsp and servlet.am using tomact servver
displaying images and records problem - JSP-Servlet
displaying images and records problem  hi, Thanks for your reply to my question. The code you sent to me last week is not working. it doesn't display any record and image. I posted my question and since then no replay
Displaying image when clicked on URL in jsp - JSP-Servlet
Displaying image when clicked on URL in jsp  Hi, I am using.../Images/abc.jpg. Similarly, many such jpg's are there. The jsp would have different... in displaying the image from the folder. Regards, Anish
Displaying Date in Servlet
Displaying Date in Servlet     ... a current date and time on our browser. It is very easy to display it on our browser by using the Date class of the java.util package.  As we know that the our
JSP Date & Time - JSP-Servlet
JSP Date & Time  Hi! How to compare a String with System time in JSP.... pls... help me... Thanks in advance
displaying a calendar of only current month in jsp on webpage using javascript
displaying a calendar of only current month in jsp on webpage using javascript  how can we display a calendar of only current month in jsp on webpage using javascript
codes for displaying in calendar
codes for displaying in calendar  can i get jsp codes for displaying comments, when the pointer is placed over the particular date in calendar
forwarding request to a jsp from a filter and displaying image in that jsp
forwarding request to a jsp from a filter and displaying image in that jsp ... correctly, but in login.jsp the image is not displaying. Can you help me in resolving this problem. Thanks & Regards, Suresh   Jsp Display Image <
Displaying Constant values from Interface in JSP - JSP-Servlet
Displaying Constant values from Interface in JSP  Hi, ******Sorry... need to display suitable fields in my jsp but this should be done upon suitable...="COMP100"; // and so on } IN HOME JSP ****** home.jsp **** Currently
String Date incremented in .jsp
String Date incremented in .jsp  I am an utter novice in jsp, but I... a String in the .jsp to be a date which is derived as Todays Date plus 90 days, in a defined format. I can hardcode a date and the .jsp works fine, but I can't
displaying both image and records problem in jsp and servlet - JSP-Servlet
displaying both image and records problem in jsp and servlet  hello, Thanks for your reply on the question i asked the other time. It worked perfectly, but it's still not what i want. What i want is that, i want
Problem displaying resultset in jsp(no frameworks used) - JSP-Servlet
Problem displaying resultset in jsp(no frameworks used)  Problem... to display the bean elements within the arraylist within my JSP. Suppose if the resultset return 25 rows, these 25 records are to be displayed in my jsp. My problem
validating credentials and displaying error message in login .jsp if not valid
validating credentials and displaying error message in login .jsp if not valid  hi, i want to validate user name and password against my database table if not valid i have to display error message in my login page.how to do
To store date - JSP-Servlet
date in database MySQL. But, date object returns day, month, and year in integer format only. If it is possible to convert from integer to date send me the method. And send the actual query to store the date also. With lots of thankzs
Advertisements
 

 

 

DMCA.com