I want to convert my Swing application to web application. Getting help from How to deploy swing application on web browser?
Please have a look to second step of first answer ("Install this [AjaxSwing] application in your system"). Where can I upload jar file and how?
You don't actually upload a jar file, I think the related answer is misleading. Webswing is a software you download and install on-premise. It starts a web server which serves your application on a web page. All you need to do is create a configuration where you specify the path to your jar file. As Gilbert pointed out, you can get the idea when you read the Webswing documentation https://www.webswing.org/docs/20.1/start/quickstart.html
Related
Well,I'm working on an Eclipse Dynamic Web Project under Tomcat.
I'm trying to make a web application/site.In a jsp/html page,there is a form where a user can upload a photo.
I handle then this action from a servlet that has to store this image/file somewhere so as to make it possible the image appears whenever I want on the site.
Here is the problem.I started by storing it on my file system,(path in a database) but when I wanted to retrieve it the page didn't appear.
I guess the reason is here:
Why can't I do <img src="C:/localfile.jpg">?
Then,I tried to store the file in the eclipse project folder(WebContent/folder) where I've stored manually some images that do appear.
File folder=new File("/TED/res/img");
File file=new File(folder,fileName);
System.out.println(file.toPath());
Files.copy(fileContent, file.toPath());
But this exception happens:
java.nio.file.NoSuchFileException: /TED/res/img/2017-08-13-123524.jpg
It's one the line of files.copy command which means that
new File(folder,fileName) that I tried failed
What should I do? From what I've read,I understood that also saving file in the IDE's project folder is also wrong but what other choice do I have?
Ultimately, the project will be deployed to a server. As such, there are three distinct issues:
Uploaded user content location: content like images should be uploaded to a folder outside your web app (project). Images inside the web app (project) should be those that are necessary for the application and provided by the developer, not user-generated.
In Eclipse, during development and testing, you will want to serve these images through Tomcat. There are many ways to do this. Tomcat configuration is probably not the best for this - please read the answer and discussion here: Simplest way to serve static data from outside the application server in a Java web application
Once the application is deployed to the server, Tomcat will most likely run behind a Web server like Apache or Nginx. In this case, the external image folder and its contained files can be served directly by the Web server. Even if you implemented a servlet in (2) for local testing with Eclipse and this servlet is part of the code that is deployed, it will not be invoked as the URL will be intercepted by the Web server before it reaches Tomcat. For example, if your uploaded image folder is C:\images on your development environment, it can be served by the servlet using the technique in (2) as /images/*. When deployed to a server, the Web server can be configured to servet /images/* from /srv/content/images and this request will never reach Tomcat.
Oracle recommends using the JnlpDownloadServlet to launch JNLP from Java web applications - https://docs.oracle.com/javase/8/docs/technotes/guides/javaws/developersguide/downloadservletguide.html
However, I need to launch a JNLP application with a dynamically generated JNLP file from a dotnet application.
What would I need to do to enable this?
set content type as application/x-java-jnlp-file
output the JNLP file as a download.
Is there anything else?
The JNLP file is just an XML file that happens to be an executable file as long as you have Java Web Start installed on your machine. This is usually installed on a machine.
From a .NET Web Application point of view, you'd need to ensure the following:
Correct content-type (application/x-java-jnlp). You might need to add configuration to your .NET server to enable this mime type.
The file needs to be accessible via a URL (kind of obvious, but worth mentioning for completeness)
The file needs to be downloadable. Conceptually it is the same as returning any other file.
For seamlessness, the browser needs to be setup to automatically execute jnlp files. Sometimes company/default browser settings do not do this and you'd end up needing an extra click. Not a big deal, but just something to be aware of
In terms of "configuring"/implementing the actual serving of the JNLP file from a .NET Application:
Your end goal is that whatever JNLP file you return is executable with Java Web Start. This gives you a nice repeatable test while you're working on this.
You need to ensure that your .NET Application is able to serve the jar files needed by the JNLP application. Typically the codebase attribute and the resources element needs to reference your .NET application. The JNLP File Structure Page should help with this.
If you look at the JNLP servlet source code you will see that all it does is use the .jnlp file as a template and substitute place holders for specific values. There is nothing special about it that couldn't be duplicated in a .Net MVC or API controller.
I have created a jsp file which will give an output in JSON format using java class and servlet, i am new to java and i don't have idea about the deployment of jsp file. Can anyone suggest me how to do it? I used to develop an asp.net web application in which there was a specific option available which called " publish project", but i cant find in eclipse.
I already have a php server in which i have uploaded few php files, can i use the same server to upload this file?
Currently, my application is running fine on localhost.
Please help me with this matter and thank you for your time.
To publish your project in Eclipse:
Right click your project
Export
Under Web > Choose WAR
Then just follow the instructions and your good to go.
It is done as a component of a WAR (Web Application Archive) file.
Upon deployment, JSP files are processed by the Servlet container. The processing effectively turns them into Servlets, such that the plain text of the JSP becomes println statements in the response of the Servlet, and the embedded Java code in the JSP becomes regular Java code in the Servlet.
The packaging details are covered in detail in the JEE7 tutorial, although earlier tutorials don't differ much in the details.
i assume you are using tomcat in your php? you can use tomcat or glassfish server to deploy your application. you just need the .war file of your application and upload it to the admin page of tomcat or glassfish server.
It should be in .war file format
Here are few links which can help you in building it from eclipse, link1, link2.
For deployment, there should be a server -- tomcat / glassfish / jboss which can provide platform to execute .war files.
IDEs and .war files are great productivity tools, but I'm of a mind that you need to understand how these things work from the command line. I'm using Apache Tomcat running on a Raspberry Pi as a development server. I developed my .jsp and then just copied to where it needed to be. In this example login.jsp needs to be in the root folder of an app called SEM. So, just copy it there and access it via its URL.
sudo cp login.jsp $CATALINA_BASE/webapps/SEM
http://localhost:8080/SEM/login.jsp
Didn't even have to restart Tomcat. :)
I have a simple web application which lets the user upload local user data and then they can generate HTML reports from that uploaded data. Once the HTML is generated, I display a link to the report which they can click on to view in their browser or they can share the link with others.
The problem is that I am currently putting the "/Upload" folder in the "WEB-INF" folder because I don't want that folder data accessible to the outside world. I am then putting the "Reports" folder in the root directory of the web application. This work fine in that I can deploy the WAR file to the their server, the user can upload the files, and then request for HTML reports to be generated. The problem is that when I send them software updates in the WAR file it deletes everyone in the /MyWebApp directory including the /Upload and /Reports folder. So then the user has to re-upload the data and they loose any of their existing reports in the "/Reports" folder.
Now I did find an answer for the /Upload folder on StackOverflow with this discussion.
Where can I put an uploading folder so that when I deploy/undeploy the site in Tomcat that folder won't be affected
But I still don't know where to put my "/Reports" folder? I thought I would have to put it in the web application context directory as I am doing now in order for the Tomcat server to serve it up as a link (e.g.: http://example.com/MyWebApp/Reports/report01.html).
The other thing to note is that this application is running on Apache Tomcat only, I don't have the request going through an Apache server. We decided to just have it running on the users local server with Tomcat because it seems easier to deploy then trying to deploy and configure both to work together. Also, there are only 2-3 people using this application per server site and with that load Tomcat seems to be doing a great job handling everything on its own. So maybe that is making the solution more difficult?
Any hep with best practices for this would be greatly appreciated.
There should be no difference between the strategy you used for placing uploaded-files on the disk with placing reports on the disk: both are files that were generated by the webapp during its deployment (forget the fact that a client uploaded the file) and need to be protected in the same way.
If you are willing to upgrade to Tomcat 7, there is a new <Context> attribute, aliases, which will allow your webapp to serve content from that directory but not delete it when the webapp is undeployed.
I am q java web apps developer.
I am using Eclipse+Tomcat.
Currently I am working on about 10 web apps.
Here is my problem:
My web apps are not all placed under a single folder, they are located in different places.
To test my changes I have to export my web apps into war files or to move the updated files manually every time so the Tomcat will recognize them.
This seems like a waste of time for me.
Is there a way to tell tomcat where my web apps located instead of copying files every time?
Are you using Eclipse Webtools?
If you're not, consider doing so. You will be able to configure Eclipse to launch Tomcat with your web applications, have them auto-reloaded, etc...
Short of that, you could still configure your Tomcat server to pick up your web applications from wherever you want by specifying appropriate document base in either server.xml or your webapp's context.xml
Here's a link to Server Tools documentation
Here comes a tutorial telling you how tomcat and eclipse are supposed to work together to forge a development environment.
http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html
Follow it and you will not be exporting the .war all the time.
You can do this easily with Tomcat. For each app you want run from somewhere else, you need to place a context fragment in $CATALINA_HOME/conf/Catalina/[host] directory. For example,
app1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/anywhere/app1" swallowOutput="true">
</Context>
The xml file name will be your context name.
You don't actually have to use Tomcat to test your apps... You can use the Jetty web server from within Eclipse, which is very comfortable.
You can try using Ant or Maven. It will solve this problems
I think you should load your application from context files rather than the server.xml. There is no need to load a application every time in the container. You can run your application from the place where it is.
Please use this link