• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what servlets are for.


If I do not want to use Servlet then is there any alternative??
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic