How to run Java Code with html..? [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am starting to build my first website with Angular&Bootstrap. I am using the Spring Tool Suite. So far my website looks pretty boring but learning CSS takes me a while.
On my website I have an input (style=file) and a button to submit. So far I managed to press a button to upload a file. I can see is as a String in the console when I log it, its working.
Now to the point where I need help:
I got a java-program that I have to use which gets the path to an XML-File and parses it. It checks if it has the right special format and reads it in. This is only a part of the whole program.
How can I use this in my Code to upload an XML-File and then check it and read it with this program? How do I use the Java-Code? So far I am only using HTML, CSS and Javascript.
Thank you for your help!

There are two options precisely available for you:
1) convert the logic which is in Java to Java script
Or
2) make it a web application and run it on tomcat(or a similar web server)
There are others too but there are a bit heavy to understand and implement.

Related

Running java program from web page [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
This is the first time I am asking a question here, so forgive me if it is a bit confusing.
I have a java app that writes a word in txt file when started. Now I want to have a button on a web page, and when I click it I want my java app to start. Pretty much I can not figure out how to start java app from web page. If anyone can help I would be really greatful.
There are several way to do this with java.
One way is to do it with Java Servlet.
You need a html form with an action that points to a Servlet (an extended Java Class)
Have a look at this tutorial
As per your question, Java Web Start (JWS) will be a good choice. Just create a .jnlp file along with your jar and then you can start a Java program through a web page

Architecture of a simple JAVA EE app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I was given the task - to create a simple JAVA EE web-application that have the following functionality:
It had an index page
I choose an algorithm and enter parameters for it on index page
Depending on chosen algorithm a statistical .csv file will be processed on its own way.
After processing the .csv file in compliance with entered parameters and chosen algorithm I get a table where I can find processed data.
I know that it's a very simple application but I don't know what to do - architecture, what kind of web layer and etc
If you install Apache Tomcat on your computer, and then run it, you will find a lot of simple examples, many of which will come close to what your are asking. Plus, once you install it, you have a server on which to run your new code. I would recommend you start there.
Apache Tomcat
I would say that if you really want simplicity, you go with just Servlets for the server-side processing, and JSP pages for the HTML views. I know, it's "vintage" almost, but will get you running in no time and without the need for any special "architecture" or framework besides the servlets API.
You can build your app as a War file with the tool of your choice and deploy it in a Tomcat server and that's it.

How to web scrape on server side? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm not sure if the title says what I needed. But that's the best way I can put it.
My requirement: I want to check if a series of engine numbers (of vehicles) are registered with the local transportation authority. They have provide a web-interface for this task, but I can only check for a single engine number at once. Usually I need to check over 200 numbers. So, its a humongous task to check each one individually.
A couple of years ago, I have created a small standalone python script to do this automatically using web scraping, but now I want to do this on a server.
A user gives all the numbers in the text file which they upload/paste the contents in to a text field. Then I'll have to submit the form on the transportation website (using web scraping) for each number and display a final status for all of them.
What I want to know is how to do this on a server? What technologies could be helpful. I'm comfortable with Java & JavaScript. I don't know PHP (But i can learn if needed). I don't have slightest Idea how to do this on server side. Any Ideas and Help is greatly appreciated.
Thanks.
Java has a library called JSoup, which provides a mostly-familiar api that uses css selectors.
And obviously there are built-in functions that can get you the html from a given URL.
Put those together and you've got a server-side scraper
[edit]
Your question, on a re-read, isn't just about scraping -- it's about how to automatically submit an html form from within Java to an external server. This is an interesting question, one I've wondered myself.
this may be an answer: How to send post form with java?

How do I pass variable(s) from a VB.NET application to an already running Java application on the same computer? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I hope this doesn't sound silly. I've looked it up but can't find anything.
Let's use this example to keep from being too general. In my VB.NET application, I want to do this:
Dim ASDF As String = "This is a string."
Dim UIOP As Integer = 54
From here, I want to send the values of these variables to a Java application that is already running locally on my computer - I don't want the program to start the application because it is already running. What would be the simplest way to achieve this? Thanks for your help!
I had a similar problem once which involved passing information from a Python program to a C++ application which was already running, same as in your case.
The most reliable solution I could find was to simply have the first program create a text file with the relevant info, and then have the second program read and destroy the file. This solution works really well if you only have to pass information between programs a few times, not continuously.
A more structured way of doing the same thing, instead of using a text file, would be to use an XML file. Both Java and VB.NET support XML data parsing, VB.NET with XmlTextReader and Java with Document Object Model. Using xml will allow you to have a hierarchical structure for your data.

Access website without browser [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am just learning java. I just want to make a simple application to access a web-site.
there is a website onto which i want to log-in through java:
and then interact with it through my interface, basically after log in, i would be writing in some text boxes and sending it.
I tried many places to do it, studied HTTP protocol but still cant make it.
can someone help me out?
Accessing a web site, logging in and interacting with forms on it is somewhat complex work, so it might not be the best choice for a first java project.
But if you want to do it, you should probably use Apache HttpComponents/HttpClient.
There are useful examples at the above link as well, which may help you get started.

Categories