wood burning stoves 2.0*
The moose likes Java in General and the fly likes I want to design a  java class (standalone) which will read Data from HTML page.Is it possible?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "I want to design a  java class (standalone) which will read Data from HTML page.Is it possible??" Watch "I want to design a  java class (standalone) which will read Data from HTML page.Is it possible??" New topic
Author

I want to design a java class (standalone) which will read Data from HTML page.Is it possible??

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
I want to design a java class (standalone) which will read Data from HTML page and when I click button on HTML then some java class should be triggered.Is it possible??

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
HTML is just text, so you can use the classes in the java.io package. The approach would be slightly different depending on whether the HTML page is a local file, or accessed over the net through HTTP.


Ping & DNS - my free Android networking tools app
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
I explain the scenario

I want to develop a standalone java application.so to enter any input into application I should use Applet or Swing/

I do not want to use Applet or Swing but I want to use HTML in the place of Applet or Swing.So I enter all input in HTML text boxes and if I click on submit button then all data should be sent to java class

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
That's what servlets are for. Of course, they need a servlet container running somewhere, so they're not exactly standalone. It is possible (and not hard) to embed a servlet container like Tomcat in a desktop Java application, though.

Furthermore, the same application could embed a browsing component like Lobo (on SourceForge) for the frontend; that way you can keep client and server within the same application.

Not a beginner's subject, though.
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Ulf Dittmer wrote:It is possible (and not hard) to embed a servlet container like Tomcat in a desktop Java application, though.


Jetty is also a good choice for an embedded servlet container.

I'm curious as to why you want to use an HTML form rather than Swing given this is going to be a standalone application.
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
That's what servlets are for.


If I do not want to use Servlet then is there any alternative??
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
Mark Vedder wrote:
I'm curious as to why you want to use an HTML form rather than Swing given this is going to be a standalone application.


because I do not know swing and not know any tool for designing
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Well I suppose you could write one. Seems a lot of unneccessary effort though; this is what Servlets do. Why don't you want to/can't you use Servlets?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

jacob deiter wrote:
That's what servlets are for.


If I do not want to use Servlet then is there any alternative??


If you want a standalone application that is using an HTML form, you are going to need to have some type of client -- such as Lobo that Ulf recommended -- that can display that HTML form. When the user hits submit, then you need to POST that form to something. If you want to use Java, than that needs to be either a Servlet or JSP. Alternatively you can write JavaScript that would "read" the HTML form and provide the data to the Java application. I am however not sure what Lobo's JavaScript support is like. And JavaScript to Java communications is not a small undertaking to learn either.

In the end, I think you are going to find that you are going to have to spend time learning something in order to create your UI. Rather than spending that time learning things that in the end are jumping through hoops to create a very convoluted UI with very confusing, hard to understand and maintain code, you would be better off learning the API that is meant to be used for writing UI's... that being Swing. Just my recommendation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I want to design a java class (standalone) which will read Data from HTML page.Is it possible??
 
Similar Threads
how to read specific data from a web page..
advantage vs disadvantages
begining level of web service
Function name requirement !
write java class for batch processing