5 Replies - 693 Views - Last Post: 21 February 2012 - 04:07 PM

#1 ohmygod64  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-May 11

dont know what's wrong with my code

Posted 21 February 2012 - 02:33 PM

Hi all, basically I have to create a webpage where user can input questions and I will answer it at some point. When the user entered the question in the textbox, it should display the question and the time when it entered. And the code below is what I've done so far but I can't see what's wrong with it....please help!!! :)



Package:-----
package newpackage;

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; 
}
}


Code for the webpage:-----
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Forum</title>
</head>
<body>
Enter a news question here
<form action=Ex24.jsp method=post>
<textarea name="question" rows=3 cols=100></textarea><br>
<input type=submit value="Save"><br><br>
</form>

Questions:
<jsp:useBean id="nl" class="newpackage.NewsStore" scope="application"/>
<%
	String[] str = new String[2];
	str[0] = "question";
	str[1] = new Date().toString();
%>
<%
Vector<String[]> theList = nl.getQuestions();
%>
<ol>
<li> <%= theList.elementAt(i)[0] + " " + theList.elementAt(i)[1] %></li>
<%
}
%>

</ol>
</body>
</html>


Mod edit - Please :code:

Is This A Good Question/Topic? 0
  • +

Replies To: dont know what's wrong with my code

#2 calvinthedestroyer  Icon User is offline

  • D.I.C Lover

Reputation: 154
  • View blog
  • Posts: 1,868
  • Joined: 13-October 07

Re: dont know what's wrong with my code

Posted 21 February 2012 - 02:49 PM

I tried viewing your page but it did not work. Can you try posting your code with the code tags?
Post your code between
 
tags
Was This Post Helpful? 0
  • +
  • -

#3 ohmygod64  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-May 11

Re: dont know what's wrong with my code

Posted 21 February 2012 - 02:55 PM

package newpackage;

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; 
}
}




<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*" %>
<%@page import="java.io.*"%>
<!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>
</head>
<body>
Enter a news story here
<form action=Ex24.jsp method=post>
<textarea name="story" rows=3 cols=100></textarea><br>
<input type=submit value="Save"><br><br>
</form>

Questions:
<jsp:useBean id="nl" class="newpackage.NewsStore" scope="application"/>
<%
	String[] str = new String[2];
	str[0] = "story";
	str[1] = new Date().toString();
%>
<%
Vector<String[]> theList = nl.getStories();
%>
<ol>

<%
for (int i=0; i < theList.size(); i++) {
	
%>
<li> <%= theList.elementAt(i)[0] + " " + theList.elementAt(i)[1] %></li>
<%
}
%>

</ol>
</body>
</html>

Was This Post Helpful? 0
  • +
  • -

#4 calvinthedestroyer  Icon User is offline

  • D.I.C Lover

Reputation: 154
  • View blog
  • Posts: 1,868
  • Joined: 13-October 07

Re: dont know what's wrong with my code

Posted 21 February 2012 - 03:33 PM

Are you sure that this is Javascript and not Java?

Quote

<%@ page language="java"


I don't recognize any of your code.
Was This Post Helpful? 0
  • +
  • -

#5 ohmygod64  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-May 11

Re: dont know what's wrong with my code

Posted 21 February 2012 - 03:59 PM

View Postcalvinthedestroyer, on 21 February 2012 - 03:33 PM, said:

Are you sure that this is Javascript and not Java?

Quote

<%@ page language="java"


I don't recognize any of your code.



Well I'm using the JSP in Eclipse.
Was This Post Helpful? 0
  • +
  • -

#6 calvinthedestroyer  Icon User is offline

  • D.I.C Lover

Reputation: 154
  • View blog
  • Posts: 1,868
  • Joined: 13-October 07

Re: dont know what's wrong with my code

Posted 21 February 2012 - 04:07 PM

Do you ave a live version of your webpage?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1