• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic Runtime Call from JSP (not being dynamic)  RSS feed

 
Chad Step
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When Runtime.exec() won't. Read it, seriously.
 
Chad Step
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!