Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling Java object from html form??  RSS feed

 
carl varola
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
if you have a java class just to display "hello world" in the classes directory of Tomcat web server.
is it possible to call that class from the html form by putting a url in the action of that form?
I'm asking that wiered question because i saw somewhere code that have a url in an action attribute of a html form that just have at the end of the name of java class.
for example:
public class Test
{
public void result()
{
System.out.println("hello world ");
}

}
----------------------------
html form:
<html>
<form action="http://localhost:8080/examples/web-inf/classes/test" method="POST" >
<input type="submit" >
</form>
<html>
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean a java class as in a servlet, yes. And that is what the action attribute of the form will refer to. In the case of your Test class, you will not be able to do that unless it extends httpServlet or GenericServlet and implement the appropriate method. doGet(), doPost(), or Service(). It's best to just extend httpServlet.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!