Please help with retrieving values from object stored in a vector
hi..
i have a class Magazine with 2 varibles name and price like this
class magazine
String name;
int price;
i have created a vector called selectedmag which stores objects of Magazine class... now each object will contain the name and price rite...
i want to print the values stored in vector ie i want to print the vector elements...like
Name: Mag1
Price: 10
which wil be present in object1...
and then
Name: Mag2
Price:15
which wil be present in object2...
and so on...
plz help...
if i give selectedmag.elementAt(position) i am not able to get the above output...plz help me.....
thanks,
Akshatha
hi,
Yes i have used a for loop to print the values... it goes like this
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
class Magazine
String title;
int price;
public class sessiontrack1 extends HttpServlet
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
res.setContentType("text/html");
PrintWriter out=res.getWriter();
HttpSession session=req.getSession(true);
// This is my vector
Vector myshoppingcart=(Vector)session.getAttribute("ShoppingCart");
if(myshoppingcart==null)
myshoppingcart=new Vector();
Magazine selectedMag=new Magazine();
selectedMag.title=req.getParameter("Title");
selectedMag.price=Integer.parseInt(req.getParameter("Price"));
//Putting Magazine object into the vector myshoppingcart
myshoppingcart.addElement(selectedMag);
session.setAttribute("ShoppingCart",myshoppingcart);
out.println("<html><body>U have selected these magazines");
out.println("<br>");
//Enumeration vEnum=myshoppincart.elements();
//here a am trying to print output the values
for(int i=0;i<myshoppingcart.size();i++)
out.println("Name:" + (Magazine)myshoppingcart.elementAt(i));
out.println("<br>");
out.println("Price:" + (Magazine)myshoppingcart.elementAt(i));
out.println("<br>");
out.println("</body></html>");
this is a servlet program.... plz suggest me how to print the values... in the following format
Name: Book1
price: Rs 10
Name:Book2
price:Rs 15
Akshatha
Similar Messages
-
Help with getting values from request. Very Strange!!
Hello,
My very strange problem is the following.
I have created three dynamic list boxes. When the user select
the first list box, the second becomes populated with stuff
from a database. The third becomes populated when the second
is selected. Now, I have used hidden values in order for
me to get the selected value from the first listbox. The
following code is my first listbox:
<SELECT NAME="resources" onChange="document.hiddenform.hiddenObject.value = this.option [this.selectedIndex].value; document.hiddenform.submit();">
<OPTION VALUE =""> Resource</OPTION>
<OPTION VALUE ="soil"> Soil </OPTION>
<OPTION VALUE ="water"> Water </OPTION>
<OPTION VALUE ="air"> Air </OPTION>
<OPTION VALUE ="plants"> Plants </OPTION>
<OPTION VALUE ="animals"> Animals </OPTION>
</SELECT>
I use the getRequest method to get the value of hiddenObject.
At this time I am able to get the value of hiddenObject to populate
the second list box.
But, when the user selects an item from the second list box
and the second form is also submitted,
I lose the value of hiddenObject. Why is this??
The code to populate my second listbox is the following:
<SELECT NAME ="res_categories" onChange="document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value; document.hiddenform2.submit(); ">
<OPTION VALUE ="" SELECTED> Category</OPTION>
Here I access a result set to populate the list box.
Please help!!Form parameters are request-scoped, hence the request.getParameter("hiddenObject"); call after the submission of the second form returns a null value because the hiddenObject parameter does not exist within the second request.
A solution would be to add a hiddenObject field to your second form and alter the onChange event for res_categories to read
document.hiddenform2.hiddenObject.value=document.1stvisibleformname.resources.option[document.1stvisibleformname.resources.selectedIndex].value;
document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value;
document.hiddenform2.submit();You will then come across a similar problem with your third drop-down if indeed you need to resubmit the form...
A far better approach would be to create a session scoped bean, and a servlet to handle these requests. Then when the servlet is called, it would set the value of the bean property, thus making it available for this request, and all subsequent requests within the current session. This approach would eliminate the need for the clunky javascript, making your application far more stable. -
Help with Reading values from static table in a .pdf file
Hi guys,
Pls try to clear this doubt of mine.
I basically have 2 files. Both are .pdf extension and they have tables in them. I need to compare certain values in one file with the corresponding values in the other table in the second file.
I need to do this programatically in c# . net
I have tried using packages like pdfbox and stuff which convert the pdf file into text. But cant I get the table as an object or something using which I can access the required rows and columns?
Also, these tables are static information. They are not a part of a form or anything like that.
Please help me with this.
Thanks.The document is corrupt. Try a backup.
-
Help with Retrieve attributes from database
Hi,
I'm using filter "Retrieve from or write to database" with select query from database by selecting attributes as column names radio button.
I'm unable to get these user attributes with column names.
For eg : select tag from test_tag where rownum=1;
I was trying so that result can be used using tag attribute (${tag}).
Please help in this regard.
Thanks,
VaniHi Vani,
After the retrieve filter, add a Trace Filter and leave it as it is. Execute the policy once and in the trace data that now will be displayed there you should be able to read out the exact name and type of the parameter. This way of identifying data/parameters etc is a recommended way of working while developing! Copy paste the Trace Data from the Trace filter here if you need help!
Cheers,
Stefan -
Help with retrieving emails from Gmail into Mail
Help! I'm helping my mom with her computer and her hard drive died (not backed up of course). She has a new hard drive now and I am importing her emails from her Gmail account into Mail. It worked great importing all the emails that she has since July 15th (the last time she retrieved mail from her Gmail account). If I go into Gmail through Safari I can she has hundreds more emails prior to this date still on their servers but they didn't download into Mail. I presume this is because Gmail knows they have been downloaded once before (to her old dead hard drive), but how do I get around this so all of her emails can be imported into Mail? The only copies are on the Gmail servers.
Thanks in advance for your help,
ScottOkay, then let's try this:
1. Quit Mail.
2. Go to Home/Library/Mail and remove (don't copy and don't empty the Trash) the POP mailbox.
3. Go to Home/Library/Preferences and remove the com.apple.mail.plist file.
4. Restart Mail, setup your POP account again and it should connect to Gmail and download all the messages. If it does, then you can delete the file and folder you previously removed. -
Please help with ejecting disk from MBP that won't book
I was in the middle of installing a Leopard update when my MBP froze.
Since I had to tunr it off, it now won't start up.
I tried a friends OSX install disk to get it working and it won't install.
Please help me eject the disk.
No matter what I do I cannot get it out.
IS there a Terminal prompt to eject it.
The install disks won't allow the command under disk utilities because it is starting up with that disk.
PLease help.hold down the trackpad button while rebooting the computer
-
Please help with script for 3D object
Hi!
I have PDF file with simple 3d object (for example a cube).
I need to make script that when user right-click to this cube, some PDF file (c:\mypdf.pdf) opening in new windows. How to make it? Thank you so much!Hi!
I have PDF file with simple 3d object (for example a cube).
I need to make script that when user right-click to this cube, some PDF file (c:\mypdf.pdf) opening in new windows. How to make it? Thank you so much! -
Hello to all! Please help with the question from China!!!Thanks a lot!
I am a real beginner on Java studing and I try to learn this all by myself.I had read some books translated from English format.But I dont think they were translated good enough.Sometime the meaning translated from English is totally different from what the Author want to express.So can you help to recommend some good English books for the beginner.I want to get start my studing on these books.Thanks in advance.
I used Thinking in Java 2 by Horton. I see there's an upcoming edition covering the new version 5 of Java,
http://www.amazon.com/exec/obidos/tg/detail/-/0764568744/qid=1103190687/sr=1-2/ref=sr_1_2/103-0972736-0816625?v=glance&s=books
In addition to the above I also bought The Java Programming Language by Gosling and others. It's not a tutorial. Instead it offers much in-depth information on why things are the way the are in Java. I didn't use much at first and found it quite impenetrable, but now I use it all the time especially when answering so called "I have a doubt" questions at this forum. -:) I think any serious Java developer should have a copy but not necessarily when starting out. The Horton tome will keep you busy for a while. And don't forget the on-line tutorials. If find the Swing tutorial especially valuable. -
I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. I have no problem sending the text messages but I'm not receivng any from iPhones at all. It has been about a week now that I'm having this problem. I've already tried fixing it myself and I also went into the sprint store, they tried everything as well. My last option was to contact Apple directly. Please help with turning my iMessage completely off so that I can receive my texts.
If you registered your iPhone with Apple using a support profile, try going to https://supportprofile.apple.com/MySupportProfile.do and unregistering it. Also, try changing the password associated with the Apple ID that you were using for iMessage.
-
Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.
Adobe - Lightroom : For Macintosh
Hal -
My main notebook crushes and now I would like to sync my Ipod with annother notebook! So what ca I do? Please help me! Greetings from Austria
See Recover your iTunes library from your iPod or iOS device.
tt2 -
Retrieve values from a HTML table !!!
Hi.
How can i retrieve values from a HTML table using javascript ?
I´m trying to use the command "document.getElementsByTagName" without success.
Thanks in advance.
EduardoHi, Deepu.
I´m still with trouble in retrieving the value in HTML.
In debug the C_CELL_ID seems to be correctly updated but
when using the command "document.getElementById" the value is always "null".
I implemented in the method DATA_CELL the code :
if i_x = 3 and i_y = 2.
C_CELL_ID = 'zs'.
C_CELL_CONTENT = 10.
endif.
And in HTML :
var ztest = document.getElementById('zs');
alert(ztest);
Could you help me please.
Many regards
Eduardo S.
Message was edited by: Eduardo Silberberg -
Hi,
How do I return two values from a
stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
Something like ?
CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
@intPeriod INT,
@strPeriod_Length NVARCHAR(1),
@dtStart NVARCHAR(8) OUTPUT,
@dtEnd NVARCHAR(8) OUTPUT
AS
then within the SSIS component; -
Kind Regards,
Kieran.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
Add a script task to check ssis variables values using,
Msgbox(Dts.Variables("User::strExtractStartDate").Value)
Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
Regards, RSingh -
Retrieving values from Database in Excel Task Pane App
So far,
I created a website with a database on Azure, I then published my App to Azure. My problem is that I'm not sure how I retrieve values from the database (in SQL: SELECT * FROM EXAMPLE_TABLE WHERE date = str). If someone could provide me with sample code,
that would be amazing! :D
It would also be very helpful if anyone knew a method to automatically update the database using information from a xml stream on another website, once a day.
Thank you!Hi,
>> My problem is that I'm not sure how I retrieve values from the database
You can use jquery ajax call to call your webserivce or REST API, which will query the database and return a json result.
Sample:
Apps for Office: Create a web service using the ASP.NET Web API
>> It would also be very helpful if anyone knew a method to automatically update the database using information from a xml stream on another website
For the database sync-up question, I suggest you posting them on the forums like SQL Server Forum.
Thanks for your understanding.
Best Regards
Lan
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Retrieving values from a table
Hi all,
I need to retrieve values from CSKS-KOSTL for values containing the pattern entered by the user. For example, if the user enters 1, need to retrieve all the KOSTL values starting with 1. But when i write a SELECT statement mentioning where kostl in '1', it is ignoring all the values like (0000001, 00001034, 0012334, and others). Only values starting with 1 is only retrieved as this is a character field and due to conversion routine, zeroes are prefixed while storing in the database.
Could any one let me know how to retrieve the values from the database in this situation?If you want to use IN operator in your where clause then you should define a range variable(R_KOSTL) which refers to CSKS=KOSTL and populate the range as below
R_KOSTL-SIGN = 'I'.
R_KOSTL-OPTION = 'CP'.
R_KOSTL-LOW = '1*'.
APPEND R_KOSTL.
and then write your select statement as .... WHERE kostl IN r_kostl.
The approach suggested by Amit should also work fine.
Thanks
Kiran
Maybe you are looking for
-
Hi all I need to Create a line which can be drawn any where in the panel. And this line can be used as the slider, if i click on the "make as Slider" button. Planing to use the decorator pattren please help me by giving some ideas.
-
How do I use windows with my mac
How do I use windows with my imac? I need to know which program I need.
-
Hi Guys! I am having big problems. I cannot use Adobe Photoshop (CS5) ....(nor Corel Paintshop Photo Pro x3 "Sorry for mentioning that on here!!! ) I am running a 1 month old Toshiba Satellite C660-1F1 with Windows 7 Home Premium 64-bit with 2GB RAM
-
How do i know if i'm connected to wifi??
I have wifi at home and when i try to connect the phone it just does not seem to do it. Am i missing something? is there somewhere on the phone that shows it's connected? help???
-
Long list of directories being indexed
when I click set up n my browser I have a long list of "directories being indexed". I have indexed everything from my external drive. How can I get rid of the extra "directories being indexed" in the set up window? I erased all apple loop index files