• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Looking for JSP help in multi line text box form submission

 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I am unbelievably new to any type of Java programming - I am mainly doing Linux scripting.  I now have a task to associate a JSP file accessible from browser to scripts in the Linux back end which are performing various tasks and eventually sending an email.

My criteria is:

First input: email address in a text box
Second input: list of files (one file per line) in a text box

JSP code should pass the inputs along to a back end Linux script (input1 = $1, input2 = $2) - the script will then perform it's functions and send an email with the same list of files provided.

From my research thus far, I have found the difference between request.getParameter returning a single value, and request.getParameterValues returning multiple values (which is what I need).  My problem seems to be the conversion of string to array when using the request.getParameterValues.  When I execute my JSP, I am getting the error:

[Ljava.lang.String;@10181f5b means that files is an array of type java.lang.String and 10181f5b is hashcode of this variable.



I am looking for a simple method of converting my array back to strings so it can be parsed to the Linux script and subsequently considered by this script in the output email.

OR otherwise pass a multi line variable list to the back end script.

Can anyone suggest?



My code...

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First off, all that Java code should be in a servlet.
Indeed it should be in a separate class that the servlet calls, that way you can test the logic without any webapp framework at all.  That's a lot easier to debug.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some other novice tips that will help you move along:
  • Don't use all uppercase for HTML. That went out in the 1990's.
  • Always use proper indentation for your code, be it Java, HTML or whatever else. Unindented code is not only hard to read, it hides the structure of the code.
  • And, as already noted, never ever ever put Java code in a JSP.
  •  
    James Bubenik
    Greenhorn
    Posts: 2
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Typical developers.  :)
     
    Dave Tolls
    Rancher
    Posts: 4801
    50
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Since you;re using Runtime.exec() it's advisable to read through this article.  The recommendations haven't really changed in the 17 years since it was written.

    In your case you'll want to use the exec version that takes an array of parameters.
    So you'll want to create a new String[] 1 larger than the files array, consisting of the cmd value and then all the files in the other array.

    ETA: But seriously.  Do not do this in the JSP!
     
    You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic