aspose file tools*
The moose likes Servlets and the fly likes Using a vector whithin jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using a vector whithin jsp" Watch "Using a vector whithin jsp" New topic
Author

Using a vector whithin jsp

mc moisan
Greenhorn

Joined: Jul 05, 2001
Posts: 9
Hello all,
I wish to add a row in <TABLE> tags which
contains <TR> and <TD> and in the <SELECT... i want to fill the OPTION VALUE with the results of a Vector named vecType.
//CODE IN .JSP
<!-- here we call the select() method to add the value and work type categories. -->
<% out.print(insertList.connect()); %>
<% out.print(insertList.select()); %>
<% Vector vecType = insertList.getVecType(); %>
<% for (int i=0, j=1; i < vecType.size(); i++, j++)
{
%>
<%= out.println("<OPTION VALUE=j>" +"j. " + vecType.elementAt(i) + "</OPTION>"); %>
<BR>
<%
}
%>
The tricky part is that after connection, i call a select() method which includes the following code.
//THE BEAN IS CALLED insertList.
public String select()
{
try
{
Connection contact = DriverManager.getConnection("jdbc racle:thin:scott/tiger@thename:PORT:thename");
Statement requete = contact.createStatement();
ResultSet resultat = requete.executeQuery("SELECT type FROM work_type");

while ( resultat.next() )
{
vecType.addElement(resultat.getString("type") );
}
}
catch
...
What i need to know is how to get it to insert in the actual <OPTION VALUE=... via the JSP and get what the vector contains???
Seems like i don't have the right way to do this.!!!
Please help and thanks for your time.
Good day!
MC (*_*)


Pretty please answer me,<BR>thanks!!!<BR>MC (*_*)
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
I hope this will work
<%@ page contentType="text/html" %>
<TABLE>
<TR>
<TD><Select name="">
<%
insertList.connect();
insertList.select();
Vector vecType = insertList.getVecType();
for (int i=0, j=1; i < vecType.size(); i++, j++)
{
out.println("<OPTION VALUE="+j+">"+(String)vecType.elementAt(i)+"</OPTION>";

}
%>
</Select></TD>
</TR>
</TABLE>

[This message has been edited by Anoop Krishnan (edited July 20, 2001).]


I just want to know is there any body call my bean's Getter and Setter methods with "Please" in front - My favorite quip from Bugzilla
mc moisan
Greenhorn

Joined: Jul 05, 2001
Posts: 9
Thanks Anoop for the reply.
Unfortunately i can't test it right now, the dataBase is down...
probably a Friday thing I will let you know as soon as tested.
Any other suggestions are more than welcome.
Great weekend to U.
MC (*_*)
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

One thing to add is that your JSP's will need to import Vector
<%@ page import="java.util.Vector,any.other.package.*"%>

When I was developing my pages on Tomcat, I didn't need to do this, but when I deployed to iPlanet, it threw ClassNotFound exceptions for the Vectors. Odd.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
If you have included the java.util.* in your bean and the bean is used as page import in JSP, tomcat gets it through beans automatically but not iPlaent.
This is my understanding and experience.
Bye
DC
mc moisan
Greenhorn

Joined: Jul 05, 2001
Posts: 9
Thanks to Mike and Dip for your help,
i had done <%@ page import="java.util.Vector" AND import="myPackage.myBean"%> !!!
thank you for the advice with iPlanet
BUT what is this iPlanet environment anyhow???
Merci,
MC (*_*)
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

iPlanet is the spawn of Satan. But that's only how I feel after just a few months of wrestling with it.
www.iplanet.com
mc moisan
Greenhorn

Joined: Jul 05, 2001
Posts: 9
Thank you Mike for your reply
Hi everyone,
By the way, i still haven't solve my initial problem with the use of class Vector, seems like either my Connection or Statement brings problem...cause the list never populates !!!
Do you have any clue of what could go wrong ???
Thanks again for your time.
Gush and gush again
MC (*|*) my eyes are getting cross side (by looking at my code)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using a vector whithin jsp
 
Similar Threads
calling a java Script file into the Jsp
Using JspWriter for Devloping Custom Tag
dependent select list options
display
page refresh problem