we need to code an online web journal management system in Java. It's not an Amazon, but also more than a Hello World.
Should we use a framework? If yes, why? What are some good Java Web frameworks out there that are simple?
Yes.
A Web framework should be used for all applications which are more complex than "Hello, World!". There's no need to reinvent the wheel. Web frameworks contain many useful tested components which you will almost certainly need on your site. They also help organize your code, often into an MVC or similar paradigm, which will make your code more maintainable.
Some Java Web Frameworks (in no particular order):
JavaServer Faces
Grails
Struts
Tapestry
Spring MVC
Apache Wicket
Play Framework
Stripes
Start developing without any framework and you will definitely notice yourself if you need one or not. Once more than half of your code is infrastructure for your web components, this can be a clue you should have chosen a framework rather than develop one yourself.
As a better example, use System.out.println() for logging, enhance that with some specialised package that also provides functionality like writing to a file, then add formatting to log messages and when you realise you spent half a year to develop your own poor home-made version of log4j (or whatever), someone will complain and say you should have chosen a logging framework from the very beginning and spend one or two weeks to learn how to use it.
Don't get me wrong, sometimes a mere System.out.println() wrapper is enough and a framework only adds overhead. Unfortunately, that scenario is a rarity these days...
EDIT: I am (or used to be) an anti-framework type of developer at the core so I've learned all the above "the hard way".
For a web framework suggestion: Apache Wicket
You should use a framework when you want to create something real and spend most of your time solving the problem at hand and not dealing with the underlying technology so much (e.g peristence, templating, infrastructure etc).
A good all around framework which provides tons of integration with other frameworks is Spring Framework.
A simple web framework is the play framework. Watch the screen cast on the playframework.org homepage. I am sure you will be convinced.
As #cherouvim mentioned, it's worth using a framework if you anticipate the need for "commodity technologies" like persistence, templating, routing, etc. That is, if you think your website will require non-trivial use of a database or complicated layouts and views (which are almost always present in a web application).
Check out Grails, it's based on the Spring framework but far easier to learn, manage, and use, in my opinion. Plus it's comparable to Ruby on Rails, which is another popular web application framework worth considering.
Related
I am thinking in starting a personal pet web project to experiment with different things and extend my knowledge.
I use Java a lot at work (for web applications :D) and was thinking in making my own in Python since I kinda like this language but never passed the simple scripts stages.
I want to step up a gear regarding Python (using 2.6.5) and don't know what to expect or what framework to choose from: Django, Pylons, web2py etc.
I also don't know how much these frameworks will offer me and how much will I have to write from scratch.
I could use a comparison with Java if somebody can provide me with. I'm thinking at filter functionalities such as sitemesh, custom tags like JSTL; In Python, can I write clean pages of HTML with tags in them or write a lot of print statements (something like servlets did in Java etc?
I don't know exactly how to phrase this question.
I actually need a presentation of how web development is performed in Python, at what level, and what the web frameworks bring to the table.
Can you share from your experience?
TIA!
hi try bottle python framework (bottle.paws.de / bottlepy.org) its really nice to use blistering fast and gets out of your way + the best thing about it is that its one single file to import, i recently migrated from PHP and i have to tell you am so ... loving it!
Python web frameworks run the full gamut of capabilities/facilities, all the way from shims around WSGI such as Bottle and Flask, all the way to full frameworks such as Django and TurboGears, and even "megaframeworks" such as Zope. Each does things slightly differently, but there will be some familiarity from one to the next.
It may sound strange, but there's no need to know "how web development is performed in Python" to start doing it.
In fact, working with language/framework/etc is a single most reliable way to get understanding of it. You won't gain a lot from one-page summaries.
Also, comparing it with Java isn't likely to help. There's no point in doing "Java-style development in Python". If you want to benefit, you'll need to clear your mind and do everything "Python-way".
As to what Python framework to choose, Django seems like like a good starting point. It's very popular, which means you won't be left without tutorials/documentation/help.
PS Short version: just do it.
Python web frameworks do it in a similar way as some Java-based frameworks. I can speak for Django here.
A good comparison could be Play! vs. Django. Both of them foster using an MVC architecture (or MTV = models, templates, views) and already provide you with a lot of things like CRUD operations in admin pages, ORM, authentication, URL configurations, a template language and much more.
Other Java-based frameworks might differ a lot, and I can't give you a general answer. Depending on the choice, there are only few differences. You can simply choose the language and framework you like the most. I'd recommend to go through some tutorials (Django tutorial, Play! framework tutorial for instance) and look which one works best for your needs.
We are beginning to build out a webapp which will probably see a lot of traffic. We dont have a lot of money, so we want to reduce hardware cost.
More or less, I think that means we will try to be as stateless as possible (as the Wicket way suggests - have bookmarkable URLs, etc. etc.)
The other problem is that we are gonna be hiring contractors (think oDesk or elance) for chunks of work - so there is the question of finding talent.
I have looked at Tapestry and seen a lot of API instability ( see: Why did you stop using Tapestry? ) which makes me reluctant to use it.
Seam and Wicket are highly stateful - not something I care for.
Grails looks to be very interesting. I know that there is a performance hit as compared to pure Java, but it might be worthwhile.
Stripes looks good, but I cant find examples of websites that have been built using Stripes
Which Java framework do you recommend for performance and simplicity ?
I would highly recommend Play! framework.
Java-based, Rails-like, easy to learn, highly productive, more and more real projects based on it, full stack, fast in coding and fast in production, active community...
The best performance is to be found with the action based frameworks (no paradigm mismatch as the component based frameworks have). My Shortlist would be Stripes first and Spring second.
Stripes Framework (Pro):
Fast
SEO friendly links
Elegant easy to understand code (1 thread per action).
Low learning curve, any Java web developer can quickly learn it.
100% open source, no chance of future license changes.
Focused and small integrates with any stack.
Stripes Framework (Against):
Less well known
Not full stack
Spring MVC (Pro):
Fast
SEO friendly links
Lots of developers have worked with Spring (but less with Spring MVC).
Full stack, part of Spring framework.
Spring MVC (Against):
Higher learning curve
More complex code: because beans need to be programmed tread safe, result is procedural code.
You might need to buy licenses from VM Ware in the future if you want to get all latest patches.
License terms can and have changed for future versions.
Full stack, you might get more than you need.
Spring-mvc with jsp's.
Spring is lightweight, everybody knows it, a lot of documentation for it and it's really simple to start developping if you use spring-mvc (specially if you use the mvc-annotations).
If you want some nice effects, you can combine it with JQuery (also for easy-AJAX).
Spring MVC and Stripes would be on my short list.
Both are light and easy and gives you more flexibility of the web application.
You might also considering looking at AJAX functionality; which parts of the pages could be simplified/smaller due to the usage of AJAX.
Check out the StripesFramework.org Stripes around the web page for a listing of websites built with Stripes. Some commerical sites include http://www.temprotect.com
Spring Roo (integrating Spring MVC) could be a good solution for you: this is pure java (easy to find freelancers), performant and easy to use with principles applied like Convention Over configuration;
Grails is also a good solution but you will need more hadware capabilities than Spring Roo and freelancers will be more difficult to find.
I want to make discussion form kind of website using java, should i just make it using JSP- Servlet - Java code or should i use some framework like struts ...
I am new to Java, but i have sufficient exposure of programming
Depends what you're trying to achieve.
As far as frameworks go I would recommend checking out Spring over Struts (Although they can be used together, Spring has an equivalent Spring-MVC).
But Spring might be a bit involved for a Java newbie, even if you do have other language experience. Maybe experiment with JSPs/servlet first and check out Spring once you're comfortable with them (I recommend Spring in Action for reading material)
... Also, if we're talking a bit more outside the box (I see someone else mentioned Scala/Lift), another alternative would be Groovy on Grails. This is based on Spring, and owned by SpringSource, but is much more fun/quick to develop with. Plus if your previous experience happens to be with dynamic langs such as Python/Ruby, Groovy would be worth checking out.
You can try Play framework too. I have watched their demo and it's programming model looks promising to me.
If you're going to use Struts then make sure to use Struts 2. I would not recommend anyone write a new app in Struts 1 as it is very verbose and requires lots of configuration. However, Struts 2 is pretty awesome. I wrote a tutorial on it if that's the route you'd like to go.
You should have a basic understanding of servlet API, but you will most probably prefer to use some web framework built upon it. Struts is just one of them, popular and simple though a little old; there are many others
To name some: Struts, Spring-MVC, Stripes, Struts2, Wicket, JSF, Tapestry, GWT... an many others.
(Struts2 is not a new version of Struts, it's rather a new version of Webworks).
Unfortunately none of them is a clear winner.
You might consider Scala with Lift. I am building my next site in this and it is a very promising, light weight, less verbose, Java language.
You WILL need to understand servlets and what you can do with them regardless what, as all modern Java-based web platforms build on top of that.
The Sun tutorial for servlets is at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
If you're asking whether to use a framework at all or just use plain JSP-Servlet-Java I'd say that as long as you have a grasp of the language and Servlet API as other have said, the extra effort to learn a framework on top of that is well worth it in the long run. If you don't use a framework you eventually find that either a lot of your code becomes tedious, repetitive 'plumbing' or that you've essentially created your own framework anyway. Creating frameworks can be fun but if you have a job to do with a deadline, using an existing one saves a huge amount of time and effort.
I posted this question: https://stackoverflow.com/questions/418597/java-and-net-for-php-programmer and the answers I was given didn't really help me out.
I read a few of the tutorials at sun.
The basic syntax I understand. The thing I don't understand and really need to (because I think my company is going to tell me start working with this) is to learn how to work with java for the web. I am a php programmer and I did some asp.net c# a few months ago. I am really not understanding how to work with java on the web.
I installed netbeans.
When I start a web project I also get asked what frameworks I want.
I don't know any java frameworks (I do know about spring but never really worked with it).
Is there no simple tutorial on how to do some java for the web??? I never had these much problems when I was first introduced to php :(
Someone help me out, or at least point me in a good direction.
You may find this question helpful.
All you really need to know is HTML, Java, and JSPs.
Creating dynamic content is very easy using JSPs and Java. You also need a webserver like Tomcat or Glass Fish.
As far as the back end Java code goes, there is no difference between that and a desktop application. The only thing that you are changing is the user interface. One of the biggest challenges with switching to a web interface is the fact that it is stateless by design.
The frameworks make web programming easier, they're not required. You can write web applications using plain old servlets and JSPs (with a web application container like Tomcat or JBoss) or even do all the HTTP I/O yourself (obviously that's pointless with Tomcat, etc, around).
A framework like Spring with Hibernate, etc, is similar to frameworks in PHP like CakePHP, they make development easier, they enforce sensible patterns (MVC) upon the programmer, the abstract code that is always going to be done the same way for this type of application. Yes, they limit your choices and abilities, and restrict the actions you can take, to varying degrees. Some are far more heavyweight than others. But there's a lot of choice in the Java world which is a strength, but you just have to spend time evaluating them, and picking one based upon your capabilities.
Take struts and tiles. You can simply use Struts as an MVC system and avoid all of the utility JSP tags it provides. It would take you a short time to rewrite the functionality you end up using yourself, but that's time you don't have, and then there's debugging, and specific domain knowledge and experience that you can't account for.
Are you familiar with MVC? There are multiple frameworks in Java that implement it. Struts is one of the more popular. It may help to start using Struts and work through a tutorial.
This tutorial is a good one that also will introduce you to spring.
This tutorial deals with struts in netbeans
By technical side, you can start downloading Tomcat and code the exercises and documentation.
By "architectural" sie, you code in Java the business logic, that is all the components that take the parameter by communication client-server (request), manipulate this and use this for create the result.
this result is give to communication server-client (response) and it appear, with presentation layer (JSP, etc) in the web page.
The explication is very preciseless and not very "orthodoxe", I know.
It's matter that you understand.
The programming model that is (in most cases) used when writing a Java web application is actually a subset of J2EE. Not a rocket science, but there's a need to know at least bits of it.
Get yourself familiar with concept of J2EE Web Container, J2EE Web application, it's descriptor (web.xml), Servlets (which are, in fact the basic "building stones" of any J2EE webapp) and, of course, JSPs.
Sun has many nice tutorials on their's web pages. Googling any of the above terms with "site:sun.com" usually brings good results (e.g. this one about the concept of Servlets: http://java.sun.com/products/servlet/articles/tutorial/ ).
I'd also forget about web frameworks first, and start with the J2EE stuff, then MVC as a design pattern. After that, go into the web frameworks. Use of a framework is usually of a great help, but even when using one, you still need to know the basics.
Since you're using NetBeans, start with the tuturials they have on their site.
http://www.netbeans.org/kb/docs/web/quickstart-webapps.html
Go through the simple tutorials on the site before you start going into the details on any frameworks.
Java webapps are pretty simple. You have your Java classes (.java) that handle your business logic and your .jsp files that handle the presentation. Try and keep them seperate. You also want to familiarize yourself with the JSTL tags and el (expression language) syntax
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am considering creating my own website using Java and am trying to decide what framework to use. However, doing a quick search for Java frameworks returns more than 50 to choose from!
My website is just going to be for my own enjoyment of building it in the beginning, but if it becomes popular, it would be good for it to have some scalability, or to at least be able to redesign for that.
What are the main differences between the more popular frameworks? Are there instances where one significantly outperforms the others? For example, high-traffic enterprise applications versus low-traffic small applications. I'm also wondering if some are much easier to learn and use than others.
Is there anyone who has experience with some of these frameworks and can make a recommendation? Does the sheer number of choices just serve as an early warning to avoid Java-based web development where possible?
I've used Tapestry 3, Wicket, Echo, and JSF fairly extensively. I'd really recommend you look those over and pick the one that appears the easiest for you, and to most closely fit the way you prefer to work.
Of them, the most comfortable for me to work with was Wicket, due to the lightweight nature of component building and simplicity of page templating. That goes doubly so if you are using your own db code instead of Hibernate or some other framework (I was never completely happy with Wicket Hibernate or Spring Integration).
Echo is great if you don't mind writing all of your layout in Java. I know that is different now, but I still think that product serves a fairly narrow niche. They change the development model with every major release as well it seems.
Tapestry is a great product, but it is obviously very different from the others in terms of development model as it is led mainly by one dude. Howard Lewis Ship is no doubt quite smart, but I am disappointed with their decision to basically forget backwards compatibility with each release. Again, though, for your needs this may not matter, and I've always found the Tapestry products pleasurable to work against.
JSF has been out for years, and still feels like something that a Struts guy built to fix all of the problems of Struts. Without really understanding all of the problems with Struts. It still has an unfinished feel to it, although the product is obviously very flexible. I use it and have some fondness for it, with great hopes for its future. I think the next release (2.0) to be delivered in JEE6 will really bring it into its own, with a new template syntax (similar to Facelets) and a simplified component model (custom components in only 1 file... finally).
And, of course, there are a million smaller frameworks and tools that get their own following (Velocity for basic needs, raw JSPs, Struts, etc). I generally prefer component oriented frameworks myself, though.
In the end, I'd recommend just taking a look at Tapestry, Wicket, and JSF and just picking the one that feels the best to you. You'll probably find one that just fits the way you like to work very quickly.
My favorite is the Spring Framework. With 2.5 Spring MVC is soooo kick ass, with new annotations, convention over configuration features, etc.
If you're just doing something super simple you could also just try using the regular Servlet API and not bother with a framework.
I recommend the component oriented Wicket framework. It allows you to write your web application in plain old Java code, you can use POJOs as the model for all components and don't need to mess around with huge XML configuration files.
I had successfully developed an online banking application with Struts when I discovered Wicket and saw how easy web application development can be!
I've recently started using the Stripes Framework. If you're looking for a request based framework that's really easy to use, but doesn't impose any limits on what you are doing I'd highly recommend it.
It's similar to struts, but it goes way beyond it. There are even some plugin projects that enable you to do use hibernate or jpa with very little configuration.
There are a lot of good frameworks out there though I've heard wicket is a good one as well, but I haven't used it.
Haven't tried it myself, but I think
http://www.playframework.org/
has a lot of potential...
coming from php and classic asp, it's the first java web framework that sound promising to me....
UPDATE: Tapestry 5.2 is out, so it's not abandoned, as it previously appeared to be. My experience is with Tapestry 4, not 5, so your mileage may vary. My opinion of Tapestry has changed over the years; I have modified this post to reflect it.
I can no longer recommend Tapestry as I did previously. Tapestry 5 appears to be a significant improvement, but my main issue with Tapestry is not with platform itself; it's with the people behind it.
Historically, every major version update of Tapestry has broken backwards compatibility with extreme prejudice, far more than one might expect. This seems to be due to the incorporation of new coding techniques or technologies that require significant rewrites.
Howard Lewis Ship (the principal author of Tapestry) is certainly a brilliant developer, but I can't say I care for his management of the Tapestry project. Development of Tapestry 5 began almost immediately after Tapestry 4 shipped. From what I can tell, Ship pretty much devoted himself to that, leaving Tapestry 4 in the hands of other contributors, who I feel are not nearly as capable as Ship. After having made the painful switch from Tapestry 3 to Tapestry 4, I felt that I had been abandoned almost immediately.
Of course, with the release of Tapestry 5, Tapestry 4 became a legacy product. I wouldn't have a problem with this if the upgrade path wasn't so brutal again. So now our development team is in the rather unenviable position: We could continue to use an essentially abandoned web platform (Tapestry 4), make the heinous upgrade to Tapestry 5, or give up on Tapestry entirely and rewrite our application using another platform. None of these options is very attractive.
Tapestry 5 is supposedly written so as to reduce the likelihood of update breakage from this point forward. A good example is in the page classes: in previous incarnations, page classes descended from a base class provided by Tapestry; incompatible API changes in this class were the cause of a large number of backward compatibility problems. In Tapestry 5, pages are POJOs which are enhanced at runtime with the "magic Tapestry fairy dust" via annotations. So as long as the contract for the annotations is maintained, changes to Tapestry won't affect your page classes.
If this is right, then writing a new application using Tapestry 5 could turn out well. But personally, I don't feel like putting my hand on the burner again.
Disclamer: I work at Vaadin (previously IT Mill)
If you are doing something RIAish, you might want to take look at Vaadin. It's an open source UI-oriented AJAX framework that, to me, is nice to use (I come from a PHP background myself).
There's a case study that compares doing the same application (i.e. two applications with the same set of features) in Icefaces and Vaadin. In a nutshell, it states that the UI development was considerably faster.
Even though the study is hosted at the company's wiki, I can assure that it's objective, genuine and truthful, although I can't force you in believing me.
After a long while of testing various solutions, for me it turned out to be:
Spring MVC for the presentation and
controller layer (NO Spring Webflow though,
because my flows are based on ajax)
jQuery for all the client side stuff
Spring Security for the, well, security aspect
Hibernate / JPA2
Jetty for the sake of continuations (comet)
One month of an extraordinarily steep learning curve, but now I am happy.
I would also like to mention that I was just a little step away from skipping all that Java stuff and learing Scala/LIFT instead. As far as I am concerned, everything in Java that is related with cutting edge web development (comet, async communication, security (yes, even with Spring Security!)) still is a bit of a hack (proove me wrong by evidence, pleeease!). To me, Scala/LIFT seems to be a more out-of-the-box and all-in-one solution.
The reason why I finally decided not to go with Scala is
as a project leader I must consider human resources and Java developers are much easier to find than Scala developers
for most developers in my team, Scala's funcional concept, as excellent as it is, is hard to understand
Cheers
Er
I've heard good things about the Spring Framework too. In general, though, I've been underwhelmed by most Java web frameworks I've looked at (esp Struts).
For a simple app I'd definitely consider using "raw" servlets and JSPs and not worry about adopting a framework. If the servlets are well written, it should be straightforward in the future to port to a framework if necessary when the app grows in complexity.
My pick is Wicket!!
All of them - that's the problem ;-)
I think for your modest requirements, you just need to code up servlets or simple jsp pages that you can serve from Tomcat server. I dont think you need any kind of web-framework (like struts) for personal web-site data
Saying "use JSF" is a little to simple. When you decide to use JSF, you have to choose a component library on top of it. Will you use MyFaces Tomahawk, Trinidad, Tobago (http://myfaces.apache.org/)? Or maybe ICEfaces (http://www.icefaces.org/)? Oh, and if you use ICEfaces, will you use JSPs or Facelets for your views?
In my opinion it is to hard to tell. Nobody has the time to evaluate all the promising alternatives, at least in the projects I work on, because they are not big enough to do three month evaluation phases. However, you should look around for some that has a big and active community and isn't gone in a year. JSF is around for some time, and since it gets pushed by sun, it will be around for some more. I can't say if it's the best choice, but it will be a good one.
http://zkoss.org - the good one
For high traffic sites I'd use a framework that doesn't manage client state on the server - Wicket, JSF and Tapestry are managing client state on the server. I'd only use those frameworks (Wicket is my favourite) if the application should be more like a desktop application. But I'd try to use a more scalable and simple REST+AJAX approach though.
Spring MVC would be a candidate, but since Spring MVC 3 it has a strange annotation overloaded programming model which doesn't use the benefits of static typing. There ore other ugly things like output parameters in methods combined with a usual return, so there are two output channels of one method. Spring MVC also tends to reeinvent the wheel and you'll have more to configure compared to other frameworks. I cannot really recommend Spring MVC though it has some nice ideas.
Grails is a convenient way to use Spring MVC and other established frameworks like Hibernate. Coding is fun and you'll quickly see results.
And don't forget that the Servlet API with a few little helpers like FreeMarker for templating is very powerful.
I have evaluated quite a few frameworks and Vaadin (http://vaadin.com/home) has percolated all the way to the top.
You should at least give it a short evaluation.
Cheers!
My pick would be Wicket (for large projects and a predictable user base), GWT (for large projects that are mostly public facing) or just a service framework (like Jersey/ JAXRS) together with a JavaScript toolkit (for small to medium projects).
I recommend Seam, especially if you need persistence.
See a few comments on some Java application Frameworks (second paragraph):
http://swiss-knife.blogspot.com/2009/11/some-java-application-servers.html
For quick and fancy GUI you can use JSF with Richfaces library.
Richfaces UI components are easy to use and handy references available with code demonstration in the demo site. Probably later when your site has more data to handle and lot of information has to be transacted in database you can plug any database access framework (ORM) with it.
Can't believe no one has mentioned GWT
My favorite way to go for really simple apps is Apache VelocityTools (VelocityLayoutServlet) with Velosurf (http://velosurf.sourceforge.net).
For more complex apps, Spring MVC or Struts 2.
Try HybridJava - that is much simpler than anything else.
I would say vaadin or wicket