Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to jar file from jsp

 
ravi san
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created jar file. When I test that in any dos prompt it is working fine. Basically this jar file will submit a job in mainframe and get a results. So I wanted call thru my jsp page. I coded like below. But it is not working. Any help/suggestion will be much appricated
ravi

 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ravi, welcome to JavaRanch!

Please use code tags when posting code samples here. They make code much easier to read.

I don't see the reason that's failing, but you're not giving us much to go on. Is there an exception thrown? What's the message and stack trace? It could just be you don't have a path to that jar file. Or are you expecting the output of running that jar command to get pasted into your page? You'd need to capture the output stream from process and write it to the out object for that to work.

However, you are completely misusing JSP, which is meant only for presentation. Scriptlets, i.e. Java code inside the <% ... > tags, have been obsolete for a solid decade now. Now, calling Runtime.exec even from a servlet isn't a great practice, but it's a whole lot better than calling it from a JSP. A better way of organizing this would be to call a servlet to do initial processing, put data you needed into request attributes, and then forward the request to the JSP to render.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this JspFaq entry, and then this article.
 
Paul Clapham
Sheriff
Pie
Posts: 20750
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll also want to examine the command which you are trying to execute. Notice that it's generated by code, and code can have bugs. So don't just look at the code which generates the command, look at the actual command which was generated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic