This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What design are ppl using for there web applications? I ask this because I've been reading a bit and different methods are suggested, namely : - Use one controller servlet, with usr-mapping linking every url to it (so that it decides which page , either static or JSP, to display). - Or use of various Controller servlets (each handling its own processing). - Some recommend using EJBs for handling processing.. while others say that in some cases using EJBs is overkill and only suggested for very large systems. - Another method is to use a framework ( eg Struts )... though considering that Im still a newby to servlets and JSP the struts documentation has just intimidated me so far. Basically looking for a little guidance to get started from ppl currently using a solution that works for them. thanks
I'm designing a modular web application framework (don't ask me why) and here's the solution I ended up using: 1 controller servlet that hides behind an url mapping, say http://localhost/servlet - I don't want it handling everything, just stuff that needs to hit a servlet, since the web server will probably do a much better job of it. I have a filter that extracts all request parameters and puts them in a rightful Map, then passes it along to the servlet. The url itself tells the servlet what to do - if the url was http://localhost/servlet/login/ then the server looks up the login workflow and executes it. The workflow returns request/session information & a view page to go to, which the servlet then redirects/forwards to. So this way you just have to code a few web-specific classes, but 95% of my web application doesn't have to know it's a web application. Coded correctly, I could even make a swing interface with minimal effort. I think that's the real beauty of the J2EE & MVC architecture, being able to develop a framework where you can almost swap components at will.
- Use one controller servlet, with usr-mapping linking every url to it (so that it decides which page , either static or JSP, to display). Another method is to use a framework ( eg Struts )... Asctually, these 2 approaches are the same thing. With the first option, you will end up writing what STRUTS has already written for you. I can completely understand your frustration with the STRUTS docs. Even buying a couple of books didn't help me at first. Here is what I ended up doing. I went back to the basics. I made JSP's and basically had a Servlet for each JSP to handle whatever form request I had. Then the Servlet redirected or forwarded me to the appropriate JSP. Not very elegent, but for what I was doing, it was simple enough and understandable. This really helped learn the basics of how JSP and Servlets work together. When my app began to grow, I began to see the need for components that STRUTS already implemented for me (Controller Servlet, Mappings, etc). So that is when I made the transition. And it was like a light went on. Once I understand how the basics of JSP and Servlets work, then saw the need for an MVC Framework on my own rather than just listening to people tell me I should do it, it all just clicked, and I haven't looked back. Now, since that was a bit off topic, on your topic, I would definatly say that most people are going with an MVC design for their J2EE apps. STRUTS is a good framework if you choose to use it. You don't have to. There are other MVC Frameworks out there. Maverik is one. Or you can just code it all yourself. But I would definatly recomend the MVC approach for any Web Application.
Hi Chris Brat I feel MVC architecture fits the web application scenario as it offers maintainability of the web applications. This is because large web applications are really difficult to maintain. For me one of the best frameworks for MVC is the struts framework. I learnt it really quickly by just going through a reference application like JPetStore. Check out the links below which my help you in learning struts.JPetStore Dont forget to check out the presentations in this site, they give you good information on architectures of applications and also a comparision of .NET architecture with J2EE Architecture. I'm currently using Struts along with Java Server Faces which is similar to web forms in .NET. Praveen