开发者

Running a java application on a web server as a web application?

开发者 https://www.devze.com 2023-03-28 08:21 出处:网络
I have a program in JavaSE which is the server side of a file upload/download application. N开发者_如何转开发ow I want to deploy and make it work on a CentOS VPS. I could simulate the client/server co

I have a program in JavaSE which is the server side of a file upload/download application. N开发者_如何转开发ow I want to deploy and make it work on a CentOS VPS. I could simulate the client/server connection on my own computer but I don't know how to make it work on a server as a web application. It will let the client to upload and download files and also view their own files.(database operations I think)

Which technology can I use for it for a JavaSE application?


It is possible to run java code via JSP (Java Server Pages). This can be a great option for running your app on the web (if it is a small app). Here's a short tutorial

If your code is more complex, I suggest you build it around a framework, e.g. Play! Framework

--EDIT--

JSP is a bit like PHP or a web templating language like Mako for Python.

You can embed tags that actual contain java code. This java code can do powerful things, it can actually be the code that you use to up/download files. As long as it doesn't contain complex OOP and the like, you can use it right in JSP.

To start off, you need the JSP environment running on your server.

Then on your web page, in between the <% %> tags, right in the java code that will up/download files.

e.g.

<%

void dldFile(String fName){
    //code to download file...
}
%>

<form>
<!--get user input-->
</form>

<% dldFile (userInputString); %>


You probably would have to rewrite a lot of code to make the switch from JavaSE to a web app.

The cool kid in Java these days seems to be Play

A simple File Upload in Play is shown in their documentation.

Link to Play tutorials

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号