I want to create a simple server application which runs on the desktop, and when I type my ip and port on the web browser, it connects to the server client which then opens a webpage with appropriate displays coded on the server application.
I read online that I need to use servlet and Apache Tomcat to make a webpage using Java.
I am wondering if there are any easier way to make a simple webpage which can contain buttons without using servlet and Apache Tomcat?
For example, I can use sockets to communicate between server and client applications. Could I change this client into typing the ip address and port on the web browser which will display a webpage created and contained in the server application and remove the need for servlet and tomcat? If so, how do I create a button on the server application so that web browser can see the button when connecting to the server application?
Thank you very much.
If I understand you correctly, you want to have a web page, but you don't want to use Tomcat (or any other servlet engine).
Although it is technically possible to write your own little web server (using server sockets etc), but what you're basically doing then is rewriting Tomcat. Writing a good web server is a daunting job, and should not be taken lightly. I think you are underestimating that. Instead, use what is already there. Tomcat is really quite easy get running.
Creating the server piece could be done with raw sockets, but I would look at at an embedded server like Jetty. I think it will save you a lot of time and headache.
http://docs.codehaus.org/display/JETTY/Embedding+Jetty
You should look into Play Framework. It will be easier then implementing Tomcat or Apache.
Version 1.2.4 is stable and feature-complete for Java, version 2.x is focused on Scala and doesn't have all the features of 1.2.4 yet.
You don't have to create a servlet. But, you need something that can parse a jsp page - it could be tomcat or some other server which has the same capabilities as tomcat. Though I am not sure if I understood your question correctly.
Related
I'm thinking about what might be the best solution to create a standalone client-server application in java with these features:
Server: it must provide APIs (probably rest?)
Client: javafx webview with angularjs to make requests to webserver.
Loader; it starts the server and the client;
The user can then manage the application directly from the webview or from the browser (to the server port)
This would also be able to create in the future a "cloud" version of the application, the client instead to query the localhost will perform to a remote server.
A solution of this type is correct?
What might be useful tools for its realization and how could it be structured?
I would like in particular a solution which does not require the use of a large Java Application Server, but something more simple that it can be included as a library.
I thought same architecture which you think because it's easy. localhost binding, angularjs, bootstrap in java Webview. one of solutions is Spring MVC Rest API with embedded tomcat. it may be not lightweight.
I've written a java program that handles certain http requests.
Now I'm asked to run this as a web service in IIS.
I've tried to export it as a jar and maybe run it like that...but I didn't succeed.
As far as I understood, I need to re-write the program as a web service or servlet and upload it this way to IIS.
My question is, how to do it (I'm using eclipse)? So far I managed to run a server but I never couldn't make my program to work. Can I have guidance please?
This is pretty old article but you can take a look here
For new IIS I'm not sure you can because Microsoft has it's own tech called .NET so I suppose it's better to use other server or use .NET
Also you can use Tomcat connector for IIS which is filter with redirect
I want to develop a standalone java application, with web browser as front end. This application will run locally and won't be making any remote server calls. I'm essentially using java, as web-browser cannot perform file operations.
I want this application to be portable: no need of installation. Just copying a folder should be enough. I want to know how it can be done, how will javascript communicate with java code.
In continuation of #Quentin's answer.
Yes, you need web server.
There are 2 principal architectures:
Create stand alone application with embedded web server
Create ordinary web application and run it on proprietary web server.
IMHO I think that the second approach is better, however it strongly depend on your application functionality.
You can take jetty or grizzly as a web container. Both can run as in embedded or stand alone modes. You are welcome to share other details of your application with the community if you need concrete advises concerning to the design of your application.
The application would need to implement an HTTP server. Then all communication would be done over HTTP.
Write a small web application as you need and Deploy it using Jetty. Jetty is a pure Java-based HTTP server and Java Servlet container. You can use it by embedded mode also.
Deployment is so easy if you use Jetty-Runner
java -jar jetty-runner.jar my.war
You don't need a local web server. Take JavaFX (embedded webkit) and implement a URL protocol handler for say "myprotocol". Then you can access it from the browser using something myprotocol://xxx.yyy.zzz
What approach can I take to solve my problem such that my Android app hosts a website (on whatever port > 1024) and also features a way to allow/block incoming client. So far i have tried manually opening a ServerSocket and injecting html then closing the socket, however it only works most of the time and only with Google Chrome...anyone have other ideas?
You could use some small servlet container like jetty - pure java and lightweight enough to fit a phone. Then you can register your servlets and maybe deploy complete war archive
Checkout iJetty. They basically ported a fully-functional Jetty implementation to Android. I've used it before both as a servlet container (deploying WAR files to it) and as an embedded server in an application I wrote. Getting it to work inside of another application takes some doing, but can definitely be done. You also have access to the source code so you can modify as needed.
I want something similar with php/jsp in java, but not on the server side, but on the client side.
Maybe I can make a html file with i/o, or with some net.* classes. But what can I use for the button on the html page ?
Thank you
It sounds like you want something like the Google Web Toolkit. You write your UI and logic in Java and it gets compiled into Javascript that then runs client-side in the browser.
Perhaps you mean you want to run an application on the local machine, but use an HTTP-based interface. In that case, you need the application to act as a web server on the local machine, then launch a web browser for "http://localhost:8080/" (or whatever port the application is listening on).
To implement this, you need an embedded web server such as Jetty.
install resin on your PC
http://caucho.com/resin-4.0/admin/starting-resin.xtp
(and JDK)
can run jsp,html on http://localhost
The question is a bit vague... maybe something like Rhino or MozSwing will help??