• 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

Dynamic Runtime Call from JSP (not being dynamic)

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a JSP page, I am trying to run a shell script.

From the command line, I call the script like:
First Code Example

It processes just fine in this scenario.

Within the .jsp page, I originally tried
2nd Code Example

this scenario did not work. The variable that is argument1 does not get populated and the program that is being called by the shell script gives me Null-Value error. (this does not happen in the first coding example.

A co-worker told me this would be the solution:
3rd Code Example

However, this gives me the same results as in the 2nd code example.

Any suggestions on what I'm doing wrong here? The shell-script argument is not getting picked up by the Runtime Call, but I don't know how to make sure it does get picked up.

------------
(If relevant, I'm doing this on Solaris 10 using Tomcat).
-----------

thank you for your help and insights.
 
Chad Step
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a different sub-forum that would have been more appropriate for this question? I didn't see one that I thought was, but the question itself is not very specific to JSP other than that is the what the code is being implemented.

I just didn't see a SE General forum that I thought would be better.
thank you.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to Java in General.

Not the type of thing you should be doing in a JSP (there shouldn't be any code in a JSP), but bear in mind that within a web app, there's no concept of a "current directory" and so you must always use full paths when referring to the file system.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When Runtime.exec() won't. Read it, seriously.
 
Chad Step
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the responses.

I know having this portion in the JSP isn't a best practice...... I've got other excuses I won't bore you with

Thanks for the link, I learned a lot from this.

In the end, the code below (same as example 3 in original post) did work. I had to go clear the cache out of Tomcat.



Frustrating that that is what it was, but I'm stronger having read the article Rob posted above. I'll consider this frustration worth it.

thanks everyone, this issue is closed!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic