Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet init param (JavaRanch mock question)

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The Element in the Deployment Descriptor for a servlet initialization parameter is :

<!ELEMENT init-param(param-name, param-value, description?)>


TRUE <<---
FALSE


Answer says true,
as I know servlet init param is defined in the DD as:



Did i read between the lines, regarding that question?
Please help!


Thanks,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init-param contains zero or more "description", one "param-name" and one "param-value".
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
description?

? means zero or more I conclude
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe

Will these work? If No, why?

<servlet>
<servlet-name>...</servlet-name>
<servlet-class>...</servlet-class>
<init-param>
<param-value>...</param-value>
<param-name>...</param-name>
</init-param>
</servlet>


<servlet>
<init-param>
<param-name>...</param-name>
<param-value>...</param-value>
</init-param>
<servlet-name>...</servlet-name>
<servlet-class>...</servlet-class>
</servlet>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order of tags does not matter in Servlets 2.4, so both will be ok.
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means, it's OK for SCWCD CX-310-081

As the exam is based on Servlet 2.4, JSP 2.0 and tld-version 1.2

Am I right Christophe??

Regards,
Khushhal
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's OK for SCWCD CX-310-081

That's right.

And be careful the Javaranch's mock exam was aimed at SCWCD2.3, so it may contain some old questions.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Remko]:
description?

? means zero or more I conclude


? means zero or one. In other words, there can be none or one <description>
sub-element.

Am I correct?


Thanks for your replies!
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Christophe

Regards,
Khushhal
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Chandra

You are right

<description> is an optional element.
And can appear zero to multiple times.

Regards,
Khushhal
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is prior to current version, the init parameters were declared like this?

<!ELEMENT init-param(param-name, param-value, description?)>

What does this mean?


Thanks,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, they were described using a DTD. Now they are using an XML schema, which you can see here.

The init-param is now defined this way : (I've done a bit of editing)

[ August 07, 2007: Message edited by: Christophe Verre ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe,

I got it.

Khushal, my reply mismatches to what you said.
I know it is zero or one. You say it is zero or more.

Please confirm!


Thanks,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the old version (DTD), description? means that there may be 0 or 1 description.
The new version tells that there may be 0 or more (minOccurs="0" maxOccurs="unbounded") description tags.
That's confusing, so try to forget about version 2.3
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chandra..

As per DTD

<!ELEMENT init-param (param-name, param-value, description?)>


It's zero or one.

But as per XML schema

<xsd:sequence>
<xsd:element name="description" type="j2ee escriptionType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="param-name" type="j2ee:string"/>
<xsd:element name="param-value" type="j2ee:xsdStringType"/>
</xsd:sequence>


It's zero to many

And I am using XML schema.

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">


Regards,
Khushhal
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very much Christopher!


Khushhal, I got your point as well.

There has been very quick replies to this thread. I appreciate this.


Thanks,
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks a good thread. We need to be always cautious on which version the exam (be it real or mock) covers! isnt it?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic