开发者

Simple Java web framework [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Can anyone recommend a simple Java web-app framework?

I want to know about web development with Java. It is very easy to work with PHP and Apache, but I need to use Java.

I have searched for Java web frameworks, but many of them are complex and difficult to configure. I need something as simple as PHP with Apache.

Tomcat and Jetty do not use the port 80, I have to keep a process to redirect connections to another port, and a transfer from a port to another port is inefficient. However, Apache uses port 80 naturally.

There are frameworks that use a complex directory structure with many configuration folders and files. Some of them use the concept of application for each folder. With Apache, it is very simple, beca开发者_如何学运维use each page is a file in "/var/www/".

I do not know anything about servlet, JSP, JSF or Java Enterprise Edition. I prefer something that mix static HTML and dynamically-generated HTML in the same file, but if I have to call a Java function many times to output HTML string, it's ok.

I want to know a simple Java Web Framework. Something to listen the port 80, interpret the HTTP protocol and show the HTML that is generated by the Java code. The OS is Linux (Ubuntu) and I do not use IDE.

Thanks


You can run Tomcat/Jetty on port 80. Just edit the server.xml (for Tomcat). On Unix/Linux port numbers < 1024 are for privileged users so you would need to run tomcat as root.

Also, running Java web apps is a little bit different than using a LAMP (or a similar) stack. You do still need to understand the concept of a Web/Servlet container

http://en.wikipedia.org/wiki/Servlet_container

Familiarize yourself with the a typical structure for a WAR (Web Archive) file. This is no different than learning about how Apache works and familiarizing oneself with basic Apache configuration with working with a LAMP stack.

This is the bare minimum one should do when venturing into Java Web development.

Take a look at web4j http://www.web4j.com/ I have never used it but it looks simplistic enough for your needs and should get you started


Check out Play: http://www.playframework.org/ I've heard good things about it.


Based on your requirement, I think JSP is all you need. It should be relatively easy to learn and lets you mix dynamic content with static HTML, can be directly accesible just like PHP scripts(If placed in correct folder), and also lets you call Java functions.

Although it requires a bit of expertise, but you can also take a look at mod_jk here: http://diegobenna.blogspot.com/2011/01/connect-tomcat-7-with-apache2-modjk-and.html

It lets you run tomcat alongside Apache, so you have both Apache and Tomcat running side by side.


You will probably want to use Jetty to deploy your servlet. Since you don't use an IDE, if you use maven it's magical to be able to run mvn jetty:run and test your application (on any port). I also recommend maven as an easy way to generate WAR files. Jersey is a light-weight REST framework.

If you are not constrained to Java but rather are constrained to the JVM, I recommend looking at Scalatra for Scala.

Tomcat and Jetty may not use port 80 by default, but they are certainly capable of using port 80.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜