...

View Full Version : Date and time problem.( I have all the coding can't get it to work)



ajstyles
02-25-2012, 03:39 PM
I need help so the specific date & time when the text is saved , appears alongside the text automatically each time a text is saved .
It currently just displays the text but NOT the DATE OR TIME the text was saved :/


Thanks a lot in adavance i am just a beginner :)
Here is the coding JSP :

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<body>
<%@ page import="java.util.Vector " %>

Enter a news story here
<form action=Exercise24.jsp method=post>
<textarea name="story" rows=5 cols=100></textarea><br>
<input type=submit value="Save"><br><br>
</form>
All news stories:
<jsp:useBean id="nl" class="newspackage.NewsStore" scope="application"/>
<jsp:setProperty name="nl" property="story"/>
<%
Vector<String> theList = nl.getStories();
%>
<ol>
<%
for (int i=0; i < theList.size(); i++) {
%>
<li> <%= theList.elementAt(i) %> </li>
<%
}
%>
</ol>
</body>
Here is the .java coding:

package newspackage;
import java.util.Vector;
public class NewsStore {
Vector<String> stories = new Vector<String>();
public void setStory(String theNews){
stories.addElement(theNews);
}
public Vector<String> getStories() {
return stories;
}
}
Here is specifc date &time coding :

<%@page contentType="text/html" import="java.util.*" %>
<!-- http://www.java-samples.com/jsp -->
<html>
<body>
This question was submitted <%= startTime %>. <br>
<%!
Date startTime = new Date();%></body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum