Results 1 to 3 of 3

Thread: I need help so the question also prints the date&time the questions was sent.

  1. #1
    Join Date
    Feb 2012

    I need help so the question also prints the date&time the questions was sent.

    I want the specific date & time which the question was asked to appear alongside the text automatically each time.
    I got the coding just can't get it to work :/
    Here is the JSP coding:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <%@ 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>
    All news stories:
    <jsp:useBean id="nl" class="newspackage.NewsStore" scope="application"/>
    <jsp:setProperty name="nl" property="story"/>
    Vector<String> theList = nl.getStories();
    for (int i=0; i < theList.size(); i++) {
    <li> <%= theList.elementAt(i) %> </li>
    Here is the coding in .java:
    package newspackage;
    import java.util.Vector;
    public class NewsStore {
    Vector<String> stories = new Vector<String>();
    public void setStory(String theNews){
    public Vector<String> getStories() {
    return stories;
    Here is the code to print the specific time the question was sent:
    This question was submitted  <%= startTime %>. <br>
    Date startTime = new Date();%></body>

  2. #2
    Join Date
    Dec 2002
    Calgary, Canada
    Here is the logic
    In your jsp page when user submits the story, you save the time on the server side with the story, then when you print the results back, you have stimestamp for each story which you can print


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Feb 2012
    I dont know how to do that. Could you please illustrate which an example of yours or using my coding. A million thanks in adavance.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center