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

New Topic/Question
Reply


MultiQuote




|