Say I have a Java HTTP server which serves REST APIs like GET/PUT/POST etc based on Jetty. I want to create a HTML interface for this server so that I can turn on/off certain features, control settings, surface server metrics etc through it.
Is there any such Java library I can use for this purpose?
I can see 2 main directions to go:
Jetty has a built-in servlet-jsp engine support that you can use for your dynamic configuration HTML pages. You can make your configuration in jsp supported forms and dispatch their processing to servlets to make the configuration model change.
An other way is to extend your REST API with the configuration relevant part and interact with it from javascript from config HTML pages.
You do not need to deploy further jars neither for 1 nor for 2.
1. is built in
2. is already deployed by you because you are using a REST implementation already
If you have a complex configuration logic with more HTML pages you might consider using JSF instead of JSP.
Related
Currently, I develop with java / spring-boot / log4j2 , and as much as I have searched I have not seen anything interesting to log directly to a web page in real-time (something like swagger style with requests, which is by configuration without having to write code) .
Do you know anything?
You need Javascript to modify the DOM of a webpage, not Java.
You could use Spring to send Server-Sent-Events (SSE) to a frontend JS library, or host a WebSocket or other REST API on some web server and use AJAX to issue requests, upon which the DOM is modified as part of a response, but this really has nothing to do with Java/Spring/log4j
If you want a packaged distribution of Spring w/ some Javascript framework, JHipster is a popular option.
I'm a bit confused about what server to use for contain both, a Vaadin application (java) and a react application.
I was using nodejs for contain my react app, now I developed my vaadin application (I've used jetty to test it out), but I want to combined them in the same server
Can I use Tomcat to contain both? How can I deploy React on Tomcat?
Can I use expressJs to contain both? How can I deploy Vaadin on expressJs?
Is there a better approach?
Thank you a lot.
You're to some degree comparing apples to oranges in this case. To directly answer you question: You can use Tomcat for both, but not Express.js.
Vaadin is an opinionated full stack framework. It explicitly covers both the part of the UI that runs on the server and the part that runs in the browser. The server part only works on the JVM, either through a servlet container such as Tomcat or deployed as a standalone process with an embedded servlet container using e.g. Spring Boot.
React a relatively agnostic client-side framework - it is explicitly designed to work with any server-side technology. It is often used together with server-side JavaScript (e.g. Express.js) because that allows the whole application to be implemented using only one language, but it is also very commonly used with a backend running with e.g. Java or C#. All you need on the server is a way of creating endpoints for accessing the backend logic. In the case of Java, the two most common solution nowadays is to do REST endpoints using Spring (either MVC or WebFlux) or JAX-RS (e.g. Jersey).
I am using java/GWT/GXT/Spring and Hibernate. I have two webapplications deployed in tomcat as below.
WebApp1 - is webapplication with GWT/Spring/Hibernate
WebApp2 - is webapplication with JSF and spring
Now i have to send some data from WebApp1 to WebApp2 and that data has to be displayed in one screen which is there in WebApp2. For that i can provide a link in WebApp1 to WebApp2. My question is is it possible to send data from one web application to another web application?
WebApp1 will have a link to WebApp2
Thanks!
For platform independent data representation was invented the xml. Use it! A simple HTTP Post and is done.
If you want to optimize and take off the overhead, you can that too.
You will need a shared resource where you can store the information in between. For Example Database, File, System, JNDI-Tree, JMS, etc.
Be careful with accessing those resources, especially file system needs a synchronization.
a direct communication via JVM is not possible.
You can also use a REST Service to get the information transfered.
Example: WEB-APP2 needs infos from WEB-APP1, then WEB-APP2 calls Service inside WEB-APP1
If you try to build two independent views on the same dataset you have to use shared resource like I mentioned already.
Yes this is possible, try out Spring Web Services
http://static.springsource.org/spring-ws/sites/2.0/
It will allow you to speak in terms of java object from both ends. Internally it converts request to XML Soap messages but this is transparent to you as the programmer and won't have to worry about it.
I got it working using the JAXB Marshaller using STS. You can right click on the xml schema file and select the jaxb option to generate the object automatically for you. So in the end, the only thing you need to generate youself is the XML Schema file. Spring WebServices can automatically generate the .wdsl for you also.
I want to use JavaFx as a front-end in my web-application. My question is that is it possible to bind Model object with the form which is developed with Java Fx.
I kindly request you to put some light on this issue.
Please let me know If you need more clarification regarding this
The main differences between Web front-ends (like Spring MVC) and rich clients (and RIAs like JavaFX) is that for web front-ends the server-side logic runs in the same JVM as the web framework while for rich clients the server-side logic and the client are running on 2 separate JVMs, one on the server machine and one on the client machine.
Rich clients are usually downloaded/ installed completely before the user can run it, while for web front-ends each HTML page is possibly first dynamically created and then send to the user as needed.
Since the user usually already has the complete rich client from start, only the actual data (DTOs) get sent back and forth using some kind of remote service e.g Web Services.
So this means that the JavaFX client cannot access the objects of the server (e.g. attached JPA entities). You need to wrap the data up and send it to the JavaFX client using some kind of service (see the Service Facade and DTO design patterns).
The main difference between JAVAFX and any Java EE framework is same as the difference between the swing applications and Java EE apps.
You can design applications using JAVAFX to be directly used on desktop or deployed as browser applets with the help of the Java browser plugin. But, using it as a framework for designing the front end of a Java EE application is not possible.
Read this post :
https://www.java.net//node/674176
I have a Web Service accessible via SOAP. Let's assume it provides a method with the signature
sayHello(String name)
Of course, I have the WSDL describing the Web Service.
What I want to do now is to generate a client web application (war archive) with a GUI that provides a form to enter the parameter for the Web Service method. In case of the example, the form must just allow to enter the value for the "name" parameter. Then, a SOAP message must be assembled and sent to the WS.
Is there any way or any framework to generate such a webapp automatically!? The actual kind of the resulting webapp is not important, it may be a GWT webapp, JSF, plain Servlet with JSP or whatever. Even a plain HTML/JavaScript client app would be OK.
I mean, there are tools to generate CRUD forms out of data models, so there must be tools to create forms for Web Services, too...
I've been googling around for a long time, but the only thing I've found is a feature of Eclipse: http://www.eclipse.org/webtools/jst/components/ws/M3/tutorials/WebServiceClient.html . Basically, this does what I want, but I'm looking for a more ..hm.. elegant way to do this ;-)
Thanks in advance,
Frank
What you are looking for is (I think) similar to what this site seems to do: link soaptest
As far as I know there is no framework that supports this out of the box.
All frameworks support the automatic generation of client stubs and artifacts and application developers use that to implement their functionality.
In your case create the HTML interface your self to test the web service.
Only .NET web services provide similar tool for testing link text
If I remember correctly, Netbeans provides simple web pages to test the functionality of web services methods (methods offered by the server). You can find a decent amount of guides showing you how to create wevservice clients on youtube. It is a relatively straight forward process.
If it is just for testing the web service: go for soapUI. It's a standalone application and (to my opinion) a must for every SOAP engineer.