Go Back   nV News Forums > Software Forums > Software Development

Newegg Daily Deals

Reply
 
Thread Tools
Old 02-22-08, 08:24 PM   #1
Tuork
Official pain in the ass
 
Tuork's Avatar
 
Join Date: May 2003
Location: 127.0.0.1
Posts: 1,197
Send a message via MSN to Tuork
Default Arrays in JSP's?

Working on a project for Uni and I have a sheitload of fields I need to pass into a webBean.

I want to use arrays for repeated similar items rather than individual strings (for example: Location1 address, location2 addresss, etc.).

Anyone know how I can do this?
All I know so far is how to send an individual parameter via navigation rules.

Thanks!
__________________
My avatar: "An obscure and non sensical pattern made to get people to post what they think it is" - Vamp

Dimitri:
Dell XPS M1530
Core2Duo T5550 1.86Ghz | 3GB DDR2 | 8600M GT 256MB | 250GB Hdd | BenQ FP202W 20" LCD | MX1000 mouse | Inspire T5400 5.1
Tuork is offline   Reply With Quote
Old 02-22-08, 11:12 PM   #2
jcrox
Mahna Mahna
 
jcrox's Avatar
 
Join Date: Jul 2006
Location: Madison, Wi
Posts: 6,134
Default Re: Arrays in JSP's?

lets say you have a form in your JSP with fields with these names:

add1
add2
add3

you fill in the data, click the submit button....

in your servlet:

private webBean bean;

create an array and populate it with the form fields
String[] adds = {request.getParameter("add1"), request.getParameter("add2"), request.getParameter("add3")};

instantiate a new bean and pass the array to the beans constructor
bean = new webBean(adds);

in your webBean constructor:

public webBean(String[] adds) {

setAddress1(adds[0]);
setAddress2(adds[1]);
setAddress3(adds[2]);
}


Is that about what you're trying to do?
__________________

Gaming

MSI MPower Z87 | 4770k | CNPS9900MAX-B | 8GB G.Skill 1866 | EVGA GTX760 |ThermalTake 850w | X-Fi Titanium | HAF | Asus PA248Q | Lycosa | Death Adder | Win8 Pro 64

Dev/Backup

MSI GD65 | 2500k | H50 | 8GB G.skill | GTX570 | Ubuntu 13.10

Laptop

17" Inspiron | i5 | 4GB DDR3 | 500GB HDD | Win7 Pro 64

jcrox is offline   Reply With Quote
Old 02-23-08, 10:06 PM   #3
Tuork
Official pain in the ass
 
Tuork's Avatar
 
Join Date: May 2003
Location: 127.0.0.1
Posts: 1,197
Send a message via MSN to Tuork
Default Re: Arrays in JSP's?

Hmm... that all makes sense to me... sort of, except I'm not sure where 'request' comes from. Is it automatically instanciated by the bean?

I recall using it from when I used regular servlets, but the examples I've seen with JSP (particularly the one given to me at uni) don't use it.

The current architecture I'm supposed to use does not involve a servlet in between the web bean and the .jsp.

Any other ideas?
__________________
My avatar: "An obscure and non sensical pattern made to get people to post what they think it is" - Vamp

Dimitri:
Dell XPS M1530
Core2Duo T5550 1.86Ghz | 3GB DDR2 | 8600M GT 256MB | 250GB Hdd | BenQ FP202W 20" LCD | MX1000 mouse | Inspire T5400 5.1
Tuork is offline   Reply With Quote
Old 02-23-08, 10:40 PM   #4
jcrox
Mahna Mahna
 
jcrox's Avatar
 
Join Date: Jul 2006
Location: Madison, Wi
Posts: 6,134
Default Re: Arrays in JSP's?

The only other way I can think of would be using a combination of a JSP declaration and JSP expressions. Sorry, I'm not sure how you'd go about doing that though... I was taught that was the "wrong" way to use Java Server Pages.... hopefully someone else here can help you.
__________________

Gaming

MSI MPower Z87 | 4770k | CNPS9900MAX-B | 8GB G.Skill 1866 | EVGA GTX760 |ThermalTake 850w | X-Fi Titanium | HAF | Asus PA248Q | Lycosa | Death Adder | Win8 Pro 64

Dev/Backup

MSI GD65 | 2500k | H50 | 8GB G.skill | GTX570 | Ubuntu 13.10

Laptop

17" Inspiron | i5 | 4GB DDR3 | 500GB HDD | Win7 Pro 64

jcrox is offline   Reply With Quote
Old 02-24-08, 10:09 AM   #5
Tuork
Official pain in the ass
 
Tuork's Avatar
 
Join Date: May 2003
Location: 127.0.0.1
Posts: 1,197
Send a message via MSN to Tuork
Default Re: Arrays in JSP's?

Thanks anyway, mate.
__________________
My avatar: "An obscure and non sensical pattern made to get people to post what they think it is" - Vamp

Dimitri:
Dell XPS M1530
Core2Duo T5550 1.86Ghz | 3GB DDR2 | 8600M GT 256MB | 250GB Hdd | BenQ FP202W 20" LCD | MX1000 mouse | Inspire T5400 5.1
Tuork is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:05 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.