File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes unable to jar file from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "unable to jar file from jsp" Watch "unable to jar file from jsp" New topic
Author

unable to jar file from jsp

ravi san
Greenhorn

Joined: Jul 27, 2012
Posts: 5
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

Joined: Oct 01, 2001
Posts: 2771
    
  10

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

Joined: Jan 10, 2002
Posts: 60059
    
  65

Please read this JspFaq entry, and then this article.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

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.
 
 
subject: unable to jar file from jsp
 
Similar Threads
jsp question - errorPage
regarding page directive: errorPage
Why this EL code part is not working
Problem with forwarding page towards error page
Problem uploading file togetherwith database insertion