Forum Moderators: phranque
public class CurrencyConverter extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {
From my html, I'm invoking CurrencyConverter.
It always errored out so I ran it from the command prompt(JAVA CurrencyConverter 100) and I get this back:
Exception in thread "main" java.lang.NoSuchMethodError: main
Do I have to have a public static void main in there? If so how would I call doGet from main.
Thanks for any replys.
public static void xxx(String[] args)
This time when I ran it, I got the following error
Exception in thread "main" java.lang.NoSuchMethodError: main
the only thing i changed was main to xxx. Should I be declaring something eles? Thanks so much
If you want to test your servlet from the command line, you'll have to have a main method that calls a modified doGet() with no arguments (since, as bcc1234 says, you can't get a new HttpServletRequest or -Response). That will test the logic, but if you're counting on some input from the Request, you'll have to find another way to pass it in.
Also, I'd think that you wouldn't want to invoke your Servlet from your page scriplets - it's been months since I've done Java, but shouldn't you be using a Bean? I thought I remembered that doGet() and doPost() were generally called as the action of an HTML form..
Best of luck,
g.
If you need to do some testing, then add System.err.print statements that would evaluate and display whatever you need and then check the error stream log of your servlet engine.