Results 1 to 4 of 4
  1. #1
    Robben is offline Member
    Join Date
    Feb 2015
    Posts
    67
    Rep Power
    0

    Default XML and Servlets

    Before I started self learning servlets I had to learn XML first and I learned that XML has no predefined tags instead they are invented, but while learning servlets I came across tags that are predefined in my eclipse i.e. <servlet-mapping> and <url-pattern>. Am I not understanding this correctly? Can anyone elaborate please? Also, can anyone provide any good books they recommend on Servlets as well as the prerequisites before learning servlets?

    Thank you.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: XML and Servlets

    The use of XML has the advantage that it can be read by both humans and computers, and is easily transportable via communication. So in order to tell the computer what to do with your servlets using XML, you have to understand what the computer expects to read. That's why the structure for the web.xml is pre-defined via a DTD (document type definition), or later, an XSD (XML Schema Definition). This way you can write the exact tags the computer is expecting to see. You cannot write invented tags and expect the computer to know what you mean. The computer is not an intelligent being. It follows rules. In this case the structure in the XML defined in the DTD or XSD.

    Here is more information about the web.xml and how its contents are supposed to be structured: web.xml Reference Guide for Tomcat - Metawerx Java Wiki
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: XML and Servlets

    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Robben is offline Member
    Join Date
    Feb 2015
    Posts
    67
    Rep Power
    0

    Default Re: XML and Servlets

    Quote Originally Posted by SurfMan View Post
    The use of XML has the advantage that it can be read by both humans and computers, and is easily transportable via communication. So in order to tell the computer what to do with your servlets using XML, you have to understand what the computer expects to read. That's why the structure for the web.xml is pre-defined via a DTD (document type definition), or later, an XSD (XML Schema Definition). This way you can write the exact tags the computer is expecting to see. You cannot write invented tags and expect the computer to know what you mean. The computer is not an intelligent being. It follows rules. In this case the structure in the XML defined in the DTD or XSD.

    Here is more information about the web.xml and how its contents are supposed to be structured: web.xml Reference Guide for Tomcat - Metawerx Java Wiki
    Very helpful answer, thank you!

    Quote Originally Posted by gimbal2 View Post
    Thank you! Going to read it right now.

Similar Threads

  1. Servlets or JSP?
    By Buli in forum Java Servlet
    Replies: 4
    Last Post: 12-15-2012, 08:19 AM
  2. Servlets class not teaching servlets
    By tsky in forum Java Servlet
    Replies: 5
    Last Post: 04-26-2011, 10:47 PM
  3. mvc using servlets and jsp
    By dush_gos in forum Java Servlet
    Replies: 6
    Last Post: 07-09-2010, 11:32 PM
  4. servlets
    By priyacvr in forum Java Servlet
    Replies: 2
    Last Post: 09-28-2009, 07:43 AM
  5. servlets or jsp
    By krishnapal in forum Advanced Java
    Replies: 1
    Last Post: 12-13-2007, 02:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •