| Author |
how to call servlet class and it's methods from shell script
|
rama ilango
Greenhorn
Joined: Dec 11, 2008
Posts: 20
|
|
i can call java class from shell script . but i can't call methods of java and sevlet. please reply me. [ December 16, 2008: Message edited by: rama ilango ]
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Welcome to JavaRanch. You can run a Java program from a shell script the same way as you do on the command line, by adding a command like: java packagename.ClassName to the script (where ClassName is the name of a class that contains a main() method). Why would you want to call a servlet from a shell script? Please explain in more detail what you want to achieve.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
Servlets are designed to be used inside the operating environment of a JEE web application container. The container provides considerable infrastructure, plus it routes traffic to and from the servlet. There are 2 reasons I can think of for wanting to run servlet code from a command line: 1. You have some sort of function you wish to use but you want to be able to invoke it via a batch process instead of by way of a web request. 2. You want to test the code in the servlet as part of an offline test suite. For reason 1, you have a couple of options. If you want the actual servlet to function, use a command-line based utility such as wget to send a request to the server and retrieve the request results. If you want the logic but don't want to have a web server running, the same general rules as reason 2 apply. For reason 2, where you don't want to talk to a running server, you can set up a batch server simulation such as the Cactus test tool. Cactus can imitate much of the infrastructure that an application server provides, but it's quicker to launch, since it's not a full-blown web server. If you just want logic functionality, the best thing to do is to move the business logic itself outside of the servlet class and into a POJO business-object class. Then you can have the servlet invoke its functionality for online use, or invoke it directly for offline use.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: how to call servlet class and it's methods from shell script
|
|
|