Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2012, 01:59 PM   PM User | #1
ajstyles
New to the CF scene

 
Join Date: Feb 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ajstyles is an unknown quantity at this point
Date and time problem.( I have all the coding can't get it to work)

I need help so the specific date & time which the text was saved , appears alongside the text automatically each time a question is asked.
It currently just displays the text but NOT DATE OR TIME the text was submitted :/
Thanks a lot in adavance i am just a beginner

Here is the coding JSP :
Code:
<%@ 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 coding in .java:

Code:
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 the coding to print the specific time WHICH THE QUESTION WAS ASKED:
Code:
<%@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>

Last edited by ajstyles; 02-25-2012 at 04:37 PM..
ajstyles is offline   Reply With Quote
Old 02-25-2012, 02:29 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia! Ask a mod to move you over to the right forum.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 02-25-2012, 02:33 PM   PM User | #3
ajstyles
New to the CF scene

 
Join Date: Feb 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ajstyles is an unknown quantity at this point
Where can i post my question then?? Thanks in adavance
ajstyles is offline   Reply With Quote
Old 02-25-2012, 02:36 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by ajstyles View Post
Where can i post my question then?? Thanks in adavance
In the right forum! That is the Java forum!

http://www.codingforums.com/forumdisplay.php?f=54
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:44 PM.


Advertisement
Log in to turn off these ads.