• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How many sites are on one tomcat

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused with this URL in the question(from whizlab simulator):

which is valid mapping to servlet :

http://www.mysite.com/base.html

or

http://www.mysite.com/myapp/base.html

when
servlet-mapping url-pattern says-

*.html


this brings a big confusion in my mind-

I know only tomcat

What is a site on tomcat ?
a webapp is a site(http://www.mysite.com/) ?
or a group of webapps is a site (http://www.mysite.com/)?
how many sites can run on one tomcat?

whenever a url comes in must it point to a particular webapp then it will be valid or it be valid otherwise as well?

 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apache Tomcat is a Java-based web server. A web server can host many web applications. If you consider the term "site" to mean "web application", then Tomcat can host many "sites."

The question about the URL is tricky. In practice, you would never have "*.html" as the value of servlet-mapping url-pattern because this would prevent you from efficiently serving static HTML pages.

The other tricky part of this question is you are not told how the domain name is mapped to the web application, so you wouldn't be able to see if "myapp" is needed or not. A domain name can be mapped in a few different ways.

These are a couple of good examples of problems with commercial online-testing for software development/design skills. In many cases, the Instructional Designers that create these tests don't have actual programming or software engineering experience. Surfing the web and asking forum questions to create a technical test is not the same as a seasoned expert creating a test.
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marcus,

When we just consider that the domain-name mapping is not part of the exam we can say that the question is about everything behind the server (www.mysite.com)
so can /base.html point to a servlet or can /myapp/base.html map to a servlet. I would say it is the last option where myapp would be the context-root of the web-app.

Have a look at the following picture


Every web-app has to have a context-root, so the question is can the web-app have a context root of an empty String (or does it need a name like myapp). The answer might be found in the HttpServletRequest interface method String getContextPath().

Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".


It seems there is a possibility that this method returns an empty String, but how to create a servlet in the default (root) context I have no idea. Maybe this is only possible by the guys who make the web-container. This makes both answers possible.....

Regards,
Frits
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok..
this makes it quite clear for me.

If we are hosting for example a web page .html in the context root of tomcat then we don't need to metion webapp name.

ex

http://localhost:8080/mypage.html

similarily a servlet could be hosted probably and that would result in a mapping like is mentioned in question.So both are true and possible mappings for the servlets.

thanks
Now, the other question ,

how many sites can run on one tomcat?



I wanted to know that in real world when some company is using Apche Tomcat as webserver\container then in that case what will be there site folder(s)?
they will only make one myapp and put it in webapps & use it as a site folder?
or they will get the whole webapps folder of tomcat and they can put myapp1, myapp2 etc?

 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marcus,

Tomcat is not relevant to the SCWCD exam. Try to post this question on the Tomcat forum.

Kind Regards,
Frits
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok..

meanwhile i read this line in spec which says that servlet can be in default web application.

Servlets in a container that were not deployed as part of aWeb application are
implicitly part of a “default” Web application and have a default ServletContext.

 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Servlets in a container that were not deployed as part of a Web application are
implicitly part of a "default" Web application and have a default ServletContext.



ok, that statement confirms that we thought earlier: these Servlets come with the container.

Regards,
Frits
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Java-based web server has two parts: a servlet container and a JSP engine.

 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic