However, according to one of the posters at http://www.coderanch.com/t/528564/patterns/Web-Application-Web-Service-inside, combining the two under one project is considered to be a bad design. But he did not give any direct reason as to why he said that it is considered to be a bad design. Can anyone enlighten me regarding this matter? Why is it considered to be a bad design? What are the advantages and disadvantages of separating the two? Why is it better to separate the web service from the web application?
Also, after studying the framework of my web application, I realize that I could only reuse one class since the other classes are bounded by Struts, so separating the 2 might really be a better choice for me.
So having the web service inside a web application is not universally a bad design?
I would say so, although what constitutes a good or bad design in any given situation can be a matter of opinion - so people are bound to disagree.
But separating the two could be a better choice since it provides more benefits?
It could, but isn't necessarily. Also, I wouldn't say it provides *more* benefits - it provides *different* benefits and different drawbacks; as is so often the case, it's a trade-off.
But having them loosely coupled will also make them more difficult to manage right? Since if I have to update a certain class from the web application, I also have to update its corresponding class in the web service?
If achieving this kind of loose coupling is important, then you should separate out the common classes into a middle layer, or app server. So there'd be two web apps left - one for the web UI and one for the WS, and both would access the same business layer. If there's only a single class that both share, that suggests to me that the WS is quite small in scope so that it probably doesn't pay off to implement any of this separation.
But ask yourself if it might be desirable to update the web UI independently of the WS, and either of them independently of the business layer; that's what should drive the decision.
Considering your case I think it should be developed as below
And of course Struts UI webapp and Webservices application are two different webapplications using same Business Services Jar as mentioned above.
Now if your requirements for UI and Webservices starts differening from each other then you will need to branch out Business services development and use some kind of versioning.
@amit punekar: Thanks! Yes, the design of my web service and web application is similar to your design. They share some JARs under the WEB-INF/lib directory. I am glad that it seems that I am in the right direction.