• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Retreiving string values

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the following code to retrieve data in a HTTP request
<%
Enumeration names;

names = request.getParameterNames();
if ((names != null) && (names.hasMoreElements())) {
while (names.hasMoreElements()) {
String name = (String) names.nextElement(); //get the value of the next element, cast it to a string

if(name.equals("orgConsTitle")){
String values[] = request.getParameterValues(name);
for (int i = 0; i < values.length; i++){String title = XMLencode(values[i]);}
}
How do I retreive the value of the String title to display in the page?
Thanks
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't test this but you'll definitely need to move your declaration of "title" from the scope of the loop:

Hope that helps!
 
Tim Wild
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks but I'm still getting errors
Is the following sufficient to instantiate the variable, does it not need a default value?

Is it possible to assign a value to the variable from within a method. I've read about instance variables etc but confess to not fully understanding it.

Thanks
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if it is declared within a method, it will need to be given an initial value. The compiler will not even allow it.
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic