Displaying Date in jsp

Displaying Date in jsp

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
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks
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
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 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
Date Scheduler - JSP-Servlet
Date Scheduler  How to schedule a date in jsp and servlet.am using tomact servver
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
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
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks   Hi, You should import...; Then use the following code to print the current date: <%= new java.util.Date
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
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
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
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
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
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
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 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
Jsp Code to store date in database - JSP-Servlet
Jsp Code to store date in database   Hi, Can u give me jsp code to store current date in to database. Thanks Prakash
jsp - Date Calendar
JSP page load error  Hi, I am getting error while loading the page in JSP. What could be the possible reason anyone
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
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
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
jsp - Date Calendar
jsp  What is the difference between JSP and .Net?  what a great question?..... you should not compare jsp wid .NET JSP is just an web.... JAVA/J2EE and .NET can be comparable. instead u can compare java's JSP
Date Coding - JSP-Servlet
Date Coding  Hi Sir. i am creating one web application in which date is compared with specific date.i.e,When current date is reached to particular given date then a particular action should happened.For example imagine
display date to jsp from database
display date to jsp from database   display date to jsp from database to calender if the start date and end date is available than calender date will disappeared or non-clickable and its show in red color. those date
date format - JSP-Servlet
date format  how to convert 2008-10-14 to 14-Sep-2008   Hi..."; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date dateStr...); System.out.println("yyyy-MM-dd date is ==>"+formattedDate); Date
jsp code for date generation - JSP-Servlet
jsp code for date generation  hai i am meyis i need a jsp program... thanks   Hi friend, For more information on Date in JSP visit to : http://www.roseindia.net/jsp/jsp_date_example.shtml http
Comparison date - JSP-Servlet
Comparison date  sir i need to display a new web page when system date is equal to given date.iit is like birthday.i am using tomact server.when birth date is reached,a new page should be displayed automatically saying happy
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
Date in JSP
Date in JSP          To print a Date in JSP firstly we are importing a class named... so that the Date class and its properties can accessed in the JSP page
displaying section in the jsp based on the sected value in drop down - Java Beginners
displaying section in the jsp based on the sected value in drop down   Hi friend, i have one problem in my jsp. i.e i have to display section on the jsp based on the selected value in the drop down list using java script code
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
How to print a webpage without url and date in jsp ?
How to print a webpage without url and date in jsp ?  How to print a webpage without url and date in jsp
java.text.ParseException: Unparseable date - JSP-Servlet
me ! .. in my project generated servlet from jsp .. is throwing an exception .. i tried a lot but failed .. jsp code is ::::: It is throwing exception .... java.text.ParseException: Unparseable date
displaying List of records from database in a jsp using ajax
displaying List of records from database in a jsp using ajax  Sir, I...;%@page import="com.tbss.RtChannels"%><%@ taglib uri="http://java.sun.com/jsp...; In between the <div></div> I have to display the records. I am displaying
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
displaying output on web page immediately whent the jsp buffer size is full. And how to set jsp buffer size in bytes
displaying output on web page immediately whent the jsp buffer size is full. And how to set jsp buffer size in bytes  Here is my requirement, I have to display output on the browser after jsp buffer is full. And I have to set
Name Displaying - JSP-Servlet
Displaying the values in text fields of a form from a javascript function in jsp
Displaying the values in text fields of a form from a javascript function in jsp  Hi all, I have a requirement like this, First i have to call a javascript function by passing 3 values from applet. And i have
get data between date using jsp with msaccess
get data between date using jsp with msaccess  hi, urgently i need program for get data between date using jsp with MsAccess database.plz any one can help me.thanks for anyone replay with regards c.b.chellappa

Ads