Vector in jsp
Hi
In my jsp a have this part of code
Vector vcTeamIds = new Vector();
Vector vcTeamNames = new Vector();
do{ // column headers adding to vector and displaying
vcTeamIds.addElement(stb1.getField(stb1.TEAM_ID));
vcTeamNames.addElement(stb1.getField(stb1.TEAM_NAME));
} while (stb1.next()); %>
and I get this error
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 40 in the jsp file: /statistik/kampoversigt.jsp
Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] /opt/jakarta-tomcat-4.1.24/work/Standalone/localhost/services/statistik/kampoversigt_jsp.java:181: cannot resolve symbol
[javac] symbol : class Vector
[javac] location: class org.apache.jsp.kampoversigt_jsp
[javac] Vector vcTeamIds = new Vector();
[javac] ^
then I changed it by prefixing it with java.util like this
java.util.Vector vcTeamIds = new java.util.Vector();
java.util.Vector vcTeamNames = new java.util.Vector();
do{ // column headers adding to vector and displaying
vcTeamIds.addElement(stb1.getField(stb1.TEAM_ID));
vcTeamNames.addElement(stb1.getField(stb1.TEAM_NAME));
} while (stb1.next()); %>
and then I this error
Can't find resource for bundle java.util.PropertyResourceBundle, key virtualpath
in the catalina.out and tomcat dies.
Please tell me what's wrong.
Lotte
Both when I prefix it or when I import the java.util I get the same error
Can't find resource for bundle java.util.PropertyResourceBundle, key virtualpath
in the catalina.out and tomcat dies
on the web I just get
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Similar Messages
-
Error while retriving the values from a vector in jsp
Vector AppDetails is set in a Attribute of request scope as.
Vector[] AppDetails = (Vector[])port.retrieveAppDetails(appID);
request.setAttribute("AppDetails",AppDetails);
But while retriving the same in the jsp by
Vector AppDetails =(Vector)request.getAttribute("AppDetails");
its giving an error as
java.lang.ClassCastException: [Ljava.util.Vector;
so i am trying with this code now
Object attr = request.getAttribute("AppDetails");
if(attr instanceof Vector)
System.out.println("is instance of vector");
} else
System.out.println("is not a instance");
System.out.println("I'm seeing a " + attr.getClass().getName());
here the output is 'is not a instance'. Suggest me on the same.You are setting the array of vector in request object, but you are trying get the object as normal vector object. that's why are you getting error. try to get the vector object as array of vector.
-
How to Call vector in Jsp from My factory class
Hi all,
I am new to singleton,I written a singleton class,One more all so name is getAllFactory(),this method returns vector which i am going to adding my data to xxDto finally i am adding this xxDto to my Vector in the singleton class.
I need help how to call that vector in my jsp page...can any body plzz suggest to me.
Thanks
dilseimport your singleton class to your JSP using page directive.
And also import Vector class.
Then as usual create object to vector class
Vector v = singletonClassObject.getAllFactory()
thats enough. -
Hello,
I have a certain Vector within my servlet class that i retrieve from my logic unit tier.
I wish to pass this Vector to the JSP page to view and use the following statements to do this :-
Vector aucItems = logic.getAuc() ;
request.setAttribute("aucItems", aucItems) ;
rd.forward(request, response);how would i go about displaying the contents in my JSP page ? i am aware i should use request.getAttribute("aucItems") to retrieve the Vector but how would i go about traversing the vector and extracting and displaying the information using the .getName() method on each object of the Vector
Thanx,
- FaeLLeIt thinks that your items variable aucItems is a
string, and is iterating through each character in
the string in this loop.
Put the ${ } signs around aucItems to tell it
otherwise.
ie:
<c:forEach var="aucItem" items="${aucItems}">
Cheers,
evnafetsHi,
I tried that just now
My new JSP file looks like this
<html>
<head>
<title>ITEMS ON AUCTION</title>
</head>
<body>
<%@page import="auction.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:useBean id="aucItems" scope="page" class="java.util.Vector" />
<jsp:useBean id="aucItem" scope="page" class="auction.Auction" />
<table>
<c:forEach var="aucItem" items="$(aucItems)">
<tr><td>Item Number : </td><td><c:out value="${aucItem.itemNo}"/></td></tr>
<tr><td>Name : </td><td><c:out value="${aucItem.name}"/></td></tr>
<tr><td>Description : </td><td><c:out value="${aucItem.desc}"/></td></tr>
<tr><td>Current Bid : </td><td><c:out value="${aucItem.bid}"/></td></tr>
<tr><td>Maximum Bidder : </td><td><c:out value="${aucItem.maxBidder}"/></td></tr>
<tr><td>Seller Id : </td><td><c:out value="${aucItem.sellerId}"/></td></tr>
<tr><td>Maximum Time Of Auction : </td><td><c:out value="${aucItem.maxTime}"/></td></tr>
<tr><td>Auction Start Hour</td><td><c:out value="${aucItem.startHour}"/></td></tr>
<tr><td>Auction Start Min </td><td><c:out value="${aucItem.startMinute}"/></td></tr>
<tr><td>Auction Start Seconds </td><td><c:out value="${aucItem.startSeconds}"/></td></tr>
</c:forEach>
</table>
</body>
</html>I tried a lot of things for over eight hours now it always thinks it is a String.
Kindly assist.
Could it be because i have to perform a getAttribute() on the request parameter ? -
I use rs.getString(1); can get three strings like "12:00-13:00", "01:00-02:00", "02:00-03:00" from sql 2000. I would like these time one by one, if it equals user select. System will show the message...then I use following code...but doesn't work because jsp said Vector not a type.(cannot resolve).... I would like to know any other methods can do the same things. hope sb help... thank you
Vector stringVector = new Vector();
while(rs.next()){
stringVector.addElement(rs.getString(1));
Iterator sv = stringVector.iterator();
while (sv.hasNext()){
if(time.equals((String)sv.next())
out.println("wrong");
else{
......I personally would use an ArrayList. From what I hear, it's better than a vector. You want to make sure that you include the line at the top
<%@ page import = "java.util.ArrayList" %>
ArrayList stringVector = new ArrayList ();
while(rs.next()){
stringVector.add(rs.getString(1));
for (int i =0; i < stringVector.size(); i++){
if(time.equals((String)stringVector.get(i))
out.println("wrong");
else{No need to bother with any of that iterator stuff. My guess is that you're not including the Vector below, or a required jar file is missing (but Vector is part of the core java package, so the file can't be missing) -
Passing vectors into JSP from Servlet and passing data back to Servlet
I have been building an MVC application.
It has a controller which instantiates classes and evokes methods to
populate vectors. These vectors are then passed into a JSP. This part of the application works fine.
What I am having trouble with is a new JSP I have designed; this will
display the data that is actioned by the FORM action. This is actioned
based on the Search criteria entered by the user. Based on this a further vector is populated and brought back to the JSP as a vector
and this is rendered via the TABLE tag. Again this works fine.
Against each of the rows displayed, I have a print checkbox which can be checked by the user. On checking the records they want to print, they should then hint a Print button which should go back to the Servlet and print the data. THIS IS WHERE I HAVE THE PROBLEM. On going
back to the servlet the checkbox values are not displayed, rather
the values that initially populate the JSP. How do I get these new values back into the vector and hence accessible from the Servlet.
Any help with be very much appreciated.
ChrisThanks for this.
Just to clarify I am not using Struts.
What I am having difficulties with is the fact that:
I can't get the checked values back to the Servlet - they keep the values they have in the bean - so as part of instantiating the bean class I set the value of the item to 'off'. The user will then check
the checkbox which should presumbably set the value to 'on'. This isn't happening because the setter method of the bean is not evoked again
because I don't come into this JSP again - the Servlet has finished here
and now needs to print the records. It can't do this because as
far as it is concerned nothing has changed since it last passed through
the vector to the JSP.
Even when I do the following:
Enumeration paramNames = request.getParameterNames();
String param = null;
while (paramNames.hasMoreElements())
param=(String)paramNames.nextElement();
System.out.println("parameter " + param + " is " +
request.getParameter(param));
what comes back is the valus of 'off' as opposed to 'on'.
The other thing is that 'request.getParameterNames()' only works
with the first record in the vector, i.e. it doesn't fetch any other
records that are rendered in the <TABLE> tag.
In desperation is there anybody out there who can help me.
Thanks
Chris
I am going to assume you are using a MVC framework
like Struts or very similar (I am assuming that from
the language you are using).
When the servlet passes the vector back to the JSP
page and you render the HTML that is passed back the
client your Vector is gone. The Vector is not
available at the HTML level that is being viewed at
the browser.
When the user selects the checkboxes and submits the
page (by clicking the print button) the controller
servlet (called ActionServlet in Struts, yours maybe
called something else) forwards the request to the
appropriate JavaBean and Servlet to process the
request. Either the JavaBean has to recreate the
Vector (not recommended) or the processing Servlet can
(better). You can do this by recreating the Vector
from scratch for the HttpRequest parameters or, at the
time of the initial request, saving Vector to a
session and then updating with the data you get back
from the client (again from the HttpRequest
parameters).
Either way you have to work with
HttpRequest.getParameter(). -
I'm returning a vector, but I'm having trouble displaying it. The vector will contain a group of users, each containing FirstName, LastName and EmailAddress. I've the servlet working, but the I'm having trouble repeating the vector.
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>User List</title>
</head>
<body>
<h1>User Email List</h1>
<%@ page import="business.*"%>
<%
Vector users = (Vector ) session.getAttribute("users");
if (users==null){
users = new Vector();
users.setFirstName(request.getParamter("firstName"));
users.setLastName(request.getParamter("LastName"));
users.setEmailAddress(request.getParamter("emailAddress"));
session.setAttribute("users", users);
%>
<table cellpadding="5" border=1>
<tr valign="bottom">
<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
</tr>
<% java.util.Vector users = (java.util.Vector)session.getAttribute("users");
for (int i =0; i<users.size(); i++){
business.Users users = (business.Users)users.get(i);
%>
<tr valign="top">
<td><p><%= users.getFirstName() %></td>
<td><p><%= users.getLastName() %></td>
<td><p><%= users.getEmailAddress() %></td>
<td><a href="../servlet/user11.ShowUserServlet?emailAddress=<%=users.getEmailAddress()%>">Update</a></td>
<td><a href="../servlet/user11.DeleteUserServlet?emailAddress=<%=users.getEmailAddress()%>">Delete</a></td>
</tr>
<%}%>
</table>
</body>
</html>Bad idea: Vector users = (Vector ) session.getAttribute("users");
if (users==null){
users = new Vector();
users.setFirstName(request.getParamter("firstName"));
users.setLastName(request.getParamter("LastName"));
users.setEmailAddress(request.getParamter("emailAddress"));
users should probably be an instance of some class User ... -
Hi,
Iam storing objects in Vector. I then store this in HttpSession.
If there is a same request, I retrieve this Vector and add more objects. Again store this in HttpSession. Finally, I retrieve this Vector in JSP and display its contents to the user.
The problem Iam having is when there is same request and I store another object, the earlier objects get replaced by this object. For example, in first request there is a object with an int value of 10. The second time I store object with an int value of 15. Now, the first object will be replaced. That is, now both obejcts have the value of 15.
What Iam doing wrong? Here is my code:
//get Session and Vector
session = request.getSession();
myArray = (Vector) session.getAttribute("myArray");
if(session.isNew() || myArray == null){
myArray = new Vector();
//Insert a object in Vector
ordersArray.add(orderedProducts);
//Insert Vector in Session
session.setAttribute("ordersArray", ordersArray);Thanks for ur help!!!Hi Raheel,
Thank you for helping me out! Unfortunately I still have not been to solve my problem.
2. session.setAttribute("ordersArray",
ordersArray); you don't need to set attribute
again because Array/Vectors are all referenced data
structures, once they altered... their values will be
automatically reflected wherever they referenced. So,
just remove this line, i am sure it is creating some
problem in your logic.I tried what you said, but no i seem to have a different problem. Now the Vector only contains one object. So after a new request the Vector only contains object for that request but it doesn't have objects for previous requests. I think I need to set Vector as a Session attribute!
Any other ideas?
Thanks!!! -
Displaying 10 records per page in JSP
Hello There,
I have vector that is populated from the sql resultset and I'm trying to use the vector in jsp to grab 10 records at a time and then have a Navigation Buttons (Next 10, Previous 10) etc. that would get the data from the vector.
Does anyone have sample code that already does this type of functionallity. Your help will be greatly appreciated in advance.
Email [email protected]
Thanks Again In Advance.Hello There,
I have vector that is populated from the sql resultset
and I'm trying to use the vector in jsp to grab 10
records at a time and then have a Navigation Buttons
(Next 10, Previous 10) etc. that would get the data
from the vector.
Does anyone have sample code that already does this
type of functionallity. Your help will be greatly
appreciated in advance.the way i've seen this done is to pass range parameters to the JSP as query parameters in the URL.
<% int begin = Integer.parseInt(request.getParameter("begin"));
int end = Integer.parseInt(request.getParameter("end"));
int max = vector.size();
%>...static content here...
<% for (int i = begin; i < max && i <= end; ++i)
%>...interrogate element i of the vector...
<% } %>then have the links in your page to advance to the next set call the JSP itself with the begin and end parameters appropriately incremented.
--p -
I am using vectors in my bean class.I am using traditional scriptlet code to get Vector in jsp using
<jsp:usebean id="tds" class="com.TrainBean" />
and i get vector like this from Bean
Vector v=tds.getName();
and i use scriptlet to print values of vector like
<%
for(int i=0;i< v.size() ;i++){Vishal_Fichadiya wrote:
ya i had tried using <C:forEach but it didnt work
can u plz give me an example so tht i can use it
wit array list and can use JSTL in thtSee this [http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL3.html] -
Hello
I am a newbe in java/jsp and i want to create a session java bean which can contain the structure of a directory tree. Like the one of windows explorer. I am having a java been containig the cuurent state of the tree. Should thid bean be a vector of vectors of vectors or is there a better way to store the trees current structure. And if i make it like vector of vectors will i be able to iterate the multidimansional vectors with jsp tags??
Any ideas on how to make the file tree?
Thnx for any tip!You can use the JSP Tree Tag I have developed. This helps you both structuring the tree model itself + it takes care of displaying the tree in a nice way. You can change all HTML code used to display the tree. Also you can build trees dynamically instead of just displaying static trees. Take a look at it here:
http://www.jenkov.dk/projects/treetag/treetag.jsp
Kind Regards,
Jakob Jenkov -
hi all,
I have the situation where the result of an end user's actions is a variable length (in terms of number of rows) HTML table. How can the JSP/Servlet be designed so that the Servlet (or elsewhere in the non-presentation logic) doesn't generate HTML?
thanks in advance.....Hi,
The jsp can make a call to some class/object that may return a variable length list (like vector). the jsp code look like this :
code:
<table><%Vector nameVector = SomeObject.getNameVector(param);for (int index=0;index<nameVector.size();index++){%><TR><TD><%=(String) nameVector.get(index)%></tr></td><%}%></table>
hope this will help you.
Anil.
Developer Technical support
Sun Microsystems, India.
http://www.sun.com/developers/support -
Do u know the best approach with data....?
I am considering the best approach for returning a resultset from a ejb to my jsp page but I dont know which approach is the best. You comment PLEASE. (As resultset cannot be serialized so returning it directly wont be considered).
Approach A � Make a custom class having get/set variables to represent each column values in the resultset, and use the class in jsp. However, I find this tedious because whenever I add to the select statement, I have to add class variables too.
Approach B � Manually manipulate data in resultset and put into a vector then return the vector to jsp
Approach C � use rowsets instead and return the rowset to jsp.
Many thanks u all...Hello,
Approach A is not recommended - you would have to leave the resultset open and so leave the connection the the database open.
Approach B is better
Approach C - well RowSets are a new thing in 1.4 which I have not tried yet. They look useful, but is your app running on 1.4? -
Report design issue for discussion
I'm going to generete several reports using JSP--session EJB,session bean
retrieve database,return result to JSP and show in browser.
I like resultset,but resultset is not Serializable, so can't send one across
the wire.
if I turn the ResultSet into a Vector,send vector to JSP,I'll have to build
diffrent structure classes for each reports.I like the resultset becuse it
seems "consolidate" for diffrent tables
JDBC2.0 provides cachedrowset,but it seems only good for small set of
data,for report,I need to return alot of data
do you have any sugguestionsSuggestion:
Unless you have a good reason, don't use EJB for this.
1) It is non-transactional (probably)
2) It is not distributed (ejbs are probably local)
3) Were it distributed, it would suck (high cost of transmission with
report-scale data)
4) You are fighting something ... if it doesn't seem natural, it probably
aint.
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"John Zhang" <[email protected]> wrote in message
news:3c080711$[email protected]..
I'm going to generete several reports using JSP--session EJB,session bean
retrieve database,return result to JSP and show in browser.
I like resultset,but resultset is not Serializable, so can't send oneacross
the wire.
if I turn the ResultSet into a Vector,send vector to JSP,I'll have tobuild
diffrent structure classes for each reports.I like the resultset becuse it
seems "consolidate" for diffrent tables
JDBC2.0 provides cachedrowset,but it seems only good for small set of
data,for report,I need to return alot of data
do you have any sugguestions -
How can i display the values in the vector in a jsp using jstl
in a task i am recieving a vector in a jsp... how can i display those vector values in the jsp using jstl.... plz help me
thanks in advance<%
here you got vector say; v
pagecontext.setAttribute("varname",v);
%>
<c:forEach var="i" items="${varname}">
<c:out value="${i}">
</c:forEach>
Maybe you are looking for
-
Where can i see what photos are stored on icloud
Hi i have lost some photo's from my computers hard drive!!!! arrrgh! the photo's were taken with my old iphone and orginally shared on my icloud account! How can i see what my icloud is storing???? HELP PLEASE!!!!
-
Hi Experts, In my Business Scenario I am using the HTTP Receiver Adapter with "Additional Query String Attributes" for adding up the "MessageID" in the HTTP Header(I am not sure whether it will be added there).. and the adapter sends the HTTP data to
-
Quality settings and I-Link Philips / SONY
Hi, THX for all answers. Now I have some more questions, sorry it never ends. ADOBE Premiere Pro CS 6.x.x / Windows 7 HP x64 1. a When exporting to a file. Wich setting do you prefer best quality to export a file? There are a lot of differens types,
-
Inventory Difference Posting to Cost Center
Dear All, I have requirements like this. If create a physical inventory counting and post it using MI20, then it will create an accounting journal and it has a cost center. I have a requirements that the cost center is determined by the Storage Locat
-
DBMS_FILE_TRANSFER?
Does anyone have a list of file types that can be copied by DBMS_FILE_TRANSFER? I know the database files such as datafile, control file, tempfile and also dum file can be moved using this package.