Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using a vector whithin jsp

 
mc moisan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 (*_*)
 
Anoop Krishnan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
mc moisan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic