Why should I learn and use struts? [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm a java developer, not seasoned, but I am familiar with most concepts reasonably well.
I recently built a website using Tomcat/JSP (~30 dynamic pages). I made the newbie mistake of including large sections of core logic in the JSP, using the rationalization that it's "just a simple project".
I learned the hard way. So I'm re-building the app now in google app engine using servlets and planning to use Velocity to implement it using a Model-View-Controller design pattern.
I'm also looking at Struts, but haven't used the framework before.
Can someone convince me why I should incorporate struts into this project? Is it really going to buy me a lot for a medium sized project of one or two people?
There is a clear cost in an extra learning curve with strut, will the benefits outweigh the costs? Or will the use of Velocity be enough to segregate the logic? Opinions?

I would look longer term than this project. As you saw, first time you use any technology is largely about making mistakes and learning from them. So this first project won't likely be a shining example of Struts usage once you're done.
Using Struts (and Tiles from what you indicate was a main concern: JSP copy and paste) will however be an excellent delve into "proper" MVC, i.e. it forces you to do things in a particularly structured way, and one which I happened to appreciate a lot, I was a big Struts fan.
That said, there are other options, e.g. Spring contains Spring MVC plus much much more. If you're going to invest in overcoming a learning curve, think about which framework will most benefit you overall in the medium term: which frameworks do employers in your area tend to look for, for example? At this point in time, I would go with Spring where I feel the momentum is but Struts is very good at what it does.

If you're going to learn a framework then I'd recommend Spring MVC over Struts. The learning curve isn't too steep and there are lots of Spring resources available on the internet.
Once you've got Spring in place you will find your application is much simpler to maintain and support. You'll also be able to add enhancements, like security, a lot easier.

First: don't let the name confuse you: Struts2 and Struts are very different frameworks.
Second: changing from JSP to Velocity can be a good or bad decisition, but that's not exactly the point. The point is to switch away from Model1 (rather ancient nomenclature, but still useful). That is, decoupling your view layer from your logic layer. (You can use JSP or Velocity for your view layer).
Furthermore, to decide your view layer is just a part of your architecture: you still must decide who will process the request and produce the data that will be sent to the view. The most basic option is to use plain servlets, but, again, it's better to use some framework. For this, there are a lot of frameworks in Java. The "action based" ones are a subset among them, perhaps the most simple to learn. Among them, the oldest is Struts; today the most used for new projects are (in no particular order) Struts2 , Spring MVC and Stripes - they are quite similar.

Learning to separate the logic is excellent. You can do that without using Velocity, Struts or any framework whatsoever, and you'll likely learn more about what it takes to do this separation if you try it with minimal help first.
Learning a framework (in fact multiple frameworks) is also worthwhile, but I wouldn't personally choose Struts as a first framework unless it's the one used by your employer or a prospective employer. If your employer is using Struts, I hope it's Struts 2, as Struts 1 is getting ancient.
The framework I like to work with the most is Wicket, but it's a radical shift from what you're currently looking at. SpringMVC is also definitely worth a look.
If your employer is already doing web development in Java using a framework, try to learn the framework that's actually in use, and ask your co-workers for help learning it.

Why you should learn Struts? My answer is: because employers often require knowledge of it, especially for maintaining of older projects. I didn't make any precise measurements, but I think that at my region JSF and Struts are used for web application development most often.
Struts is a quite old web framework, and it's quite clumsy to write modern AJAX GUIs with it, so there were created better frameworks. JSF is for me a bit less clumsy, but also has some problems. My favourite web frameworks are Vaadin and GWT, but I'm not suggesting anything for you - you should make the decision by yourself.

Related

JSF or MVC with Servlets/JSPs or other frontend frameworks? [closed]

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 10 years ago.
I'm working on development of a social web application using Java. I need to develop the frontend/GUI of my application for web browsers.
I'm wondering what is the better strategy to do frontend development, whether using frameworks like JSF 2.0 & like OR simply following MVC approach with servlets and JSPs ?
As I have heard JSF really makes the development simpler but also the learning curve is not too low, so is it worth learning JSF or I should prefer to directly proceed with servlets/JSPs ?
I'm new to web applications development using Java & I've almost completed writing the business logic for the application.
Please justify your answer on the basis of following parameters:
Performance & costs
Ease of Development & Time (considering the learning time as well)
Future Maintenance of code
Any other parameters you consider important
Update (07-09-2012):
I finally went with JSF-2.0 & have no regrets till date. Learning curve is not steep. It's easier & development is fast with component libraries like Primefaces. There are some costs as to state saving but those things can be handled intelligently. Community is big & things are well documented now. Hopefully, in near future Stateless JSF is also coming which will boost JSF with extra high performance.
For a hobby webapp, homebrewing some MVC framework is not bad. It's a nice learning exercise tour. However, it will bite you on the long term, for sure if you publish on the web and it becomes popular. Most of existing MVC frameworks are very well thought out. Most of the unforeseen caveats are taken into account. The sole framework API is well maintained and documented by a third party.
Also, whenever your webapp becomes popular and you need more developers to work on it to fulfill the enduser requirements/wishes, it's easier to find someone who's already familiar with an existing framework. With a homebrewed and possibly buggy MVC framework, you'll likely find less developers who are eager enough to dive into another learning curve before taking over the maintenance which they'll probably never reapply on their future jobs/projects.
This does not specifically apply on JSF, but on every other existing and popular MVC framework as well, such as Spring MVC. As to JSF in general, well, I've written a lot about it before here. Here are some good starting points to read the one and other about it:
JSF versus plain HTML/CSS/JS
JSF adoption and popularity
What are the disadvantages of JSF 2.0?
For modern web apps like yours, and if your responsibility is the UI, you really don't want any "abstraction layer" stand between you and your html/css/javascript. Don't use any "component" framework.
I have heard JSF really makes the development simpler
Did you hear that from real webapp developers who actually used JSF in real products? Or just JSF committee patting their own backs? Or some old timers' wishful thinking that they don't need to learn the darn javascript?
If you choose JSF, please report your experience back to us after you shoot yourself out of frustration.
It's better use some MVC framework.
You can use either component based framework:
JSF = mostly standard, but its hard to learn and a lot of people don't like itTapestry = quite big and probably good framework
Wicket, GWT - smaller component based frameworks, handy, powerful, smart, but I haven't used them yet
Or you can use request oriented framework.
Spring MVC, Struts 2 = They are very similar. Spring MVC have probably better documentation
Struts - I do NOT recommend this, when you can use Struts 2, or Spring MVC - you can trust me in this point
Each framework have its pro-and-con it depend on situation and your knowledge. I cannot give you single-valued answer.
Spring MVC is very easy to learn and if you have a simple web app and you want to save your time, its better than JSF.
However if your web app is not so simple, JSF beats Spring MVC by far. Its model is more complicated, but it is much better structured and it is widely supported, so that you don't have to reinvent the wheel again in most of the cases. Complex gui can done with JSF with less effort.
You might want to consider Tapestry 5 if you're exploring options. We've been happily using it for many years on a large project in the social media space. It's an easy to use MVC framework that's component based. We're able to develop rapidly with it, especially now that we've built up a lot of our building blocks.
Learning time is probably on par with ramping up on any new framework. I'd perhaps say it's less than JSF and more than Spring MVC, though it really depends on what you're already familiar with and how deeply you use things. I put together a very small project on github a while back to get started with Tapestry 5 quickly, if you're interested it's tapstack.
As for long term use of a Tapestry based application, it has served us well. Maintenance of the code has been much better than when were using JSP. It's very stable as well. We've served billions of page views through Tapestry without any major problems.
On the downside it is less common than some other web frameworks. It is definitely a little different too. We feel it's worth it though, and refreshing to work with. Ultimately it's going to depend on what you need and what you feel works best for you. Best of luck with your decision.

Wanting to write web applications in Java, I'm in total bewilderment concerning which platform/framework/language to use? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I'm currently confused about the many options concerning developing Web Applications with Java. I've worked on some Java programming using Servlet/JSPs only, in the past most of my work was on PHP.
I'm trying to select a good base for me to start. The options I've considered are the following:
Option 1. Pure JSP/Servlet programming with Hibernate for the Back-end.
Problems: Maintaing a web.xml for every servlet, strict types, needing to recompile and restart tomcat everytime a change is made, lots of code.
Option 2. Groovy on Grails
Problems: Still not a mature technology, might be difficult to debug, might turn out to be slow.
Option 3. Web Application development using the Spring Framework
Problems: Seems like a chubby framework. Skeptic about it, I dont want to be limited by a framework that covers everything, I prefer using small vertical libraries like Guice, Hibernate, JSP/Servlet.
Out of my scope: JSF, Struts, Tapestry. Those three I didn't feel comfortable reading about or using.
I need help, can anyone please provide me a relieving answer to the above? Thanks.
If you can not decide on what to use, there are only 3 ways to do it, and the choice is yours:
Open your local job-search web page and find which technologies are currently popular in your region. If you choose it this way - you will have most money (statistically you should).
Input various technologies in the search box on stackoverflow and see the amount of results. Pick up the one with most results. This will mean the biggest community resulting in getting the help easier if something goes wrong.
Trying them all out yourself. Every human is different, there are ones prefering assembler, and other trying to code everything in Javascript. You can't just ask which of the platforms is generally better - you have to try them out yourself.
I suggest to add the play framework to your list.
Just another links for my commentators ;) : How to demo the play framework
BTW - my recommendation is mainly based on their tutorial. After studying these pages, I thought for the first time, next time I do a web application. Those guys seem to know what web developers really need. (again - my personal impression)
I recomend to use GWT, you can keep programming in pure java
http://code.google.com/intl/es-ES/webtoolkit/
Then all pure java experience, books, libraries and hours of work will be useful without needing another language, that was the google idea behind that.
There is also a Java Web Toolkit (and one for C++), but I haven't tried them yet
http://www.webtoolkit.eu/jwt
Option 1: It's a good option if you add some libraries to it to avoid re-programming what it has been programmed already (see out of scope paragraph)
You don't need to maintain a web.xml for every Servlet. You must maintain one web.xml per application running in Tomcat. Strict types = less bugs. What's the problem with restarting tomcat? You develop with Eclipse for example, who has a server integrated so you don't need to deploy to see your changes and when you reach certain milestone or release, you deploy to production server.
Option 2: I have no experience whatsoever with it. But slow? Don't think so. Difficult to debug? You come from PHP...I'm sure you find it easier :).
Option 3: Spring is a huge factory with tons of various tools and items. Then you take that items and construct a bike or a tank out of them. (Thanks to Max comments)
Out of your scope: JSF is on top of JSP so does a lot of stuff for you, and helps you develop a MVC pattern. It provides you with a nice framework, which is easy to understand if you already know JSP. I'd give it a second try. Also consider using GWT, maybe is what you are looking for.
My two cents: I'd go with Hibernate and JSF (and Richfaces) or GWT. You'll learn, you'll have fun, you'll get what you want. Grails and Groovy has become really popular lately. I'm sure if you choose them you'll learn and have fun too.

How do I get started building web apps with Java? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to start web developing with java. I don't know how to start, what to learn,
or what is the best web framework to learn and use. Help me out?
I assume, that you're only new to web apps and not to Java itself.
For a starter, I can recommend the Apache Wicket framework for the front end. Their web site is full of examples, the mailing lists are a great place to get started, and Wicket in Action was an enjoyable read.
If you want to work with Java Server Pages (JSP), then you should definitely also include Java Server Faces (JSF) which make working with JSPs a lot easier. I can't advocate any good books to you as I went for web tutorials mainly. You might want to have a look at Apache MyFaces.
For the business logik, I guess the standard is Enterprise JavaBeans (EJB). I liked Mastering Enterprise JavaBeans 3.0. An older version of the book is available for free at TheServerSide.com. You should avoid EJB versions older than 3.0, because they are a PITA!
A separate part of the EJB 3.0 specification is the Java Persistence API 1.0 (see, e.g., Apache OpenJPA though the documentation is patchy). Other frameworks that support JPA are, e.g., Spring or JPOX (now being called DataNucleus).
Finally, if you want an application server for testing, there are JBoss by RedHat, SUN's Glassfish and Apache Geronimo (I preferred the last one, but you may have noticed my preference for Apache projects already ;-))
Good luck!
Well if you do not know much about Java, then first I suggest going back and getting your foundation in Java strong first (cause after all JSPs are java code embedded inside HTML), then proceed to learning about servlets and then move on to JSPs.
As far as learning JSPs is concerned, I would suggest buy a book, Head First Servlets and JSP is pretty good book.
Head First Servlets and JSP
JSP Tutorial
Getting Started with Web application - JSP/Servlet
I think Grails is a great way to get started. You can use the scaffolding to get started quickly, which allows you to dip down into the more complex aspects of Java web development at your own pace. I recommend you watch this screencast to see what you think.
This is a big subject and you will need to learn a lot.
I can recommend first learning Java very well.
Head First Java - http://books.google.dk/books?id=5VTBuvfZDyoC
The Java Tutorial - http://java.sun.com/docs/books/tutorial/
You will need to be very proficient in Java, as most framework documentation expect this of you.
When you have those under your belt, you are much better equipped to determine which framework is best for you, as that very much depends on which facilities you actually need, and which you do not have any use for.
The WEB4J tool is likely worth a look.
It has a much smaller number of classes in comparison with other tools. It is "full stack", so it helps you build all parts of your web app. Thus, you don't have to learn several different tools - just one.
A college instructor related to me that he felt it was "almost perfect" for his students, since it was at just the right level, and didn't hide things behind complicated abstractions - it was plain to see how all the parts worked together.
If you know java you can always start reading this book, https://secure.manning.com/books/deshmukh It will give you the basic foundation for java web development.

How to transition from OO development to Web-Development? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 months ago.
Improve this question
I just graduated last year and I landed a job in the CRM space, specifically with Salesforce.com and its respective platform. My problem is that there are 2 languages used to do things on this platform one is relatively similar to java and is OO the other is a web-development language similar to js, but not quite. I come from a java background.
I have had limited practice with web development in the past and was always interested in it but found it difficult.
Now that I have been thrust into this world I'm finding it hard to complete tasks simply because things do not function the way I am used to in the OO world. I'd write code that would compile, test and get aggravated when things simply do not function as expected!
What do you guys suggest would be best for me to read and comprehend in order to transition my OO thinking into web-development thinking.... I'm thinking I should learn things such as 'states, MVC etc etc.' but just don't know where to begin...
Thanks for all the help!
If you mean Object Oriented with the shortcut OO I have to disagree, because most web development languages are in fact object oriented (and you really shouldn't switch from a object oriented to a procedural server sided programming language). So what you of course need is understanding of your server sided language, be it PHP, Java, Ruby or whatever and that all of them in the end just generate some form of String output (which usually HTML). So you should be aware of all the technologies and how they interact (e.g. HTML, CSS, JavaScript/AJAX, your server sided language framework and so on) and have a understanding of how the transport protocol (meaning mainly HTTP) works and what the disadvantages/advantages are.
If you already did more OO development you should at least have heard about MVC which is (with some adaptions to HTTP being a stateless protocol) probably one of the more important patterns to transfer into and use in the web dev world.
It sounds like you are having trouble getting started with Apex and Visualforce, the two technologies used for development on the Force.com platform.
I'd recommend reading through the developer.force.com site. In particular check out the tutorials.
As far as object oriented development with Apex goes, start by reading Object Oriented Apex - Practical Usage.
It might also be worthwhile to cruise through the message boards and see what questions other people are asking. The community is pretty active. If you have specific questions, you can ask them or stackoverflow.
In my experience, working on web projects instantly reduces my productivity by 50%. It takes me twice as long to get something working in a web project compared with a compiled executable program.
You're working in mutliple languages that interact in ways that you need to control in a very specific way. Your mindset changes depending on if you're writing code for the client-side, or server-side. (Some of this goes away if you're doing Google's Web Toolkit coding).
I won't even go into the added difficulties of debugging web based products when compared with debugging a typical executable.
Most of the langauges do support some form of Object Orientation, and when they don't, typically developers will separate functionality into different files based on Object Oriented techniques. I think you'll find that knowledge will still apply.
Web development fully embraces OO if used with frameworks like .NET and JSF.
You need to start thinking in terms of web application logic and behavior. The OO concepts are there to help you and be your tools.
If you mean client side languages like Javascript/action scripts. Try Dojo framework for javascript development, it has a great model using an OO approach.

Is Java suitable for "Web 2.0" applications? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I was chatting to someone the other day who suggested that Rails and PHP are the most suitable platforms for web applications, and to avoid Java. My background is mainly Java, and I know that it is considered by some to be too verbose and "heavyweight", but is used occasionally (e.g. by LinkedIn).
So I'm wondering whether anyone has had success using Java for a recent web application that has gone live, either using the language itself (e.g. with Stripes/Spring + Hibernate), or the runtime with a dymamic language (such as JRuby, Groovy, Jython)? If so, please share what worked and what you would do differently.
Some background (added later):
Tim O'Reilly coined the phrased "Web 2.0" and here is his definition: http://www.oreillynet.com/lpt/a/6228
I think it's the "End of the release cycle" and "Lightweight programming model", involving rapid iterations and simplified deployment, where Java may be less suitable. Thoughts?
I would argue that there is no specific technology for Web 2.0. The main concept behind a Web 2.0 application is that much of the content is provided by it's users and not one specific person. If you can achieve this with Java, then that is fine. Many people are creating startup companies with technology that is free because they don't have the capital.
there are two totally different concepts called 'Web 2.0':
user generated content (usually with some 'social networking')
dynamic AJAX-based web apps
the second one somewhat dictates the technologies that you have to use (at least some JS, and machine-readable content in (some) responses). of course, there's nothing against using Java (or CGI, Perl, whatever) on the server.
the first one doesn't have anything to do with technology, and everything to do with the service itself you're providing. again, you can use anything you want.
why are these two mixed in the same therm? and more to your point: why are dynamic languages assumed 'more appropriate' for it? i'd guess it's just a temporal coincidence, all three things (user-generated content, AJAX, serious dynamic languages) jumped to the limelight roughly at the same time, and most of the proponents of each concept are using the other two.
in short, better avoid undefined marketroid terms like "web 2.0", and use proper descriptions. at least while working. when selling to the VCs and PHBs use any and all buzzwords that come near!
Of course it is. Java has some extremely mature and well tested frameworks for doing web applications, including so called Web 2.0 websites. Hibernate, Spring, even Struts and Tiles, or even Plain Old Servlets will do.
In addition, Java is very fast (see the Debian speed tests) compared to Ruby, which is good for websites handling lots and lots of requests, which Ajax does tend to inflate the number of! :)
Your friends, with all due respect, are dolts. Java is a rich language with incredible tools support. You could build a fantastic backend in Java and use anything you want for the front end.
It took me a while to figure out what to say in this answer because I was agape at the sheer craziness of the notion.
Where I work, all our applications are built using Java. They are web apps, built using either hibernate or direct JDBC on the data end, and using Struts or JSF for the presentation side. I would not work with JSF again unless we had access to the latest version (we were stuck on 1.0 because of our IDE) as we encountered MANY issues with it and were told that they had been fixed in later versions. As for the rest of the technologies, they work fine if you know how to use them.
In general, you are going to be better off developing in a language you know well and is capable of doing the job than in one you barely know but may be the "best" language for the job.
"Web 2.0" more often than not refers to the user interface than the underlying technology powering the webapp.
What's stopping a Java-based webapp from being totally flashy and AJAX-y in the UI layer? Nothing. You'll be writing the middle layers in Java - which is transparent to the user anyway.
I think that the people who gave you this advice are more concerned about being "hip" and (what they perceive to be) current with what is "hot" right now - which is totally irrelevant to the markup of your UI. I wouldn't listen to them.
Wonderful day, I get to post about Wicket again! :)
Java is very suitable for Web2.0 applications as long as you know how to use the tools which are available for you. The Apache Wicket I just linked is a POJO-based web application framework with such incredible way to hide all that boring server-client stuff that it allows you to do just about anything you can think of. The strong point here is that since Wicket is just POJOs, you can get very fast, iterative and unit tested code that works just as one would expect in browser.
To create Web2.0 sites with Java you don't of course have to use Wicket but I'd recommend it anyway.
I build Web apps at work in Java and then I use PHP for my personal projects. While Java is certainly capable of all that you might require it to do, I've found it a little cumbersome at times and have wished I was using PHP (or another language, for that matter). It does depend on what type and size of application you're building, but I think there are good reasons why many people choose PHP, Ruby and Python for their personal projects, i.e. where they get to choose what language they build Web apps in (and not their superiors).

Categories

Resources