• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion on 3 Servlets Parts.

 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers ,

It has been a quite a while i am learning Servlets and Jsp and i am happy that i have rised from Level 0 to Levl 8 out of 10. Thanks for Kathy and Bert for their wonderful book on JSP and Servlets.

While i was reading that book , three questions in my mind and those are the questions which is irritating me. Would appreciate if everyone here who are at their best level please explain answer to my question.

1) if i have 1000 Servlets , do i have to provide servlet and servlet-mapping for all those 1000 Servlets ? There isnt a way out to this ?

2) If web.xml (Deployment Descriptor ) file becomes huge enough , is there a way we can define more then 1 web.xml file i.e divide them. The similar sort of thing i have seen in Struts wherein if struts-config.xml file goes huge , we divide it in 2 parts. Is there a way out for web.xml as well ?

3) For the welcome-file-list , Can i provide something like Test.do which actually would be pointing to some servlet defined up in the servlet element in DD ?

Our expert's opinions would be very much appreciated.

Thanks in Advance.

Yogendra N Joshi.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Yogendra Joshi:
1) if i have 1000 Servlets , do i have to provide servlet and servlet-mapping for all those 1000 Servlets ? There isnt a way out to this ?


Explore the Front Controller pattern. It is discussed in this article.

2) If web.xml (Deployment Descriptor ) file becomes huge enough , is there a way we can define more then 1 web.xml file i.e divide them.


No, but there's no need for it to get so big. See answer to #1.
[ July 22, 2007: Message edited by: Bear Bibeault ]
 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi bear ,

Thanks for the help on 1st and 2nd question. I went through your article and Front Controller is the exact solution to it.

But what about the 3rd question on welcome file list. Can you put some light on it please ?

Thanks for replying

Yogendra
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can also use servlets in the welcome-file-list
 
li bei
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried that providing something like Test.do into the welcome-file-list ,so I don't know it work or not.
But , if you want to use Test.do as your welcome-file,you can do like this:
provide a index.html ,set it into the welcome-file , and in the body :

<body>
Loading,please wait...
<script language="javascript">
window.location.href="Test.do";
</script>
</body>

I do it like this.
I hope that would help
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by li bei:
I do it like this.


A JavaScript solution is really inefficient.

For containers that are not up to date (supporting servlets in the welcome list), you'd be far better off using a forward or a redirect.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you web application contains 1000 servlets , then its a big project and
you would definitely not be just using servlets and jsp's for making it.
In future maintaining that would be difficult.

In that case you would be going for some MVC framework , like Struts and struts has a Front Controller.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as you actually have a file named "index.html" (or whatever you've listed in your welcome-file entry) you can also have a servlet mapping for the same url.

See: WelcomdFileHack in on my site:
http://simple.souther.us
It allows you to use a servlet for a welcome file, even on containers that don't support it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahul Bhattacharjee:
In that case you would be going for some MVC framework , like Struts and struts has a Front Controller.


Or just a simple Front Controller. I don't think it's ever necessary to have to take on a monster like Struts.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Considering the web application under consideration to be very big ,we can make use of a lot of features that struts provides apart form Front Controller , like validation , slitted struts-file (related to second point of the original post) , etc.

And apart from the 1000 servlets of the application , if any more servlets are required to be added at later point of time then it can be added without much issues and maintaining the application would become much easier.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All of those features are just as relevant or irrelevant for small as for large apps. I continue to contend that just because an application gets "big" that it does not need an over-engineered behemoth like Struts to maintain.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic