aspose file tools*
The moose likes Product and Other Certifications and the fly likes how to I use servlets with xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "how to I use servlets with xml" Watch "how to I use servlets with xml" New topic
Author

how to I use servlets with xml

calvin gomes
Greenhorn

Joined: Aug 01, 2003
Posts: 1
an XML file, called agents.xml, containing the details of at least 5 travel agents. The structure of the file is as follows:
<agents>
<agent iatanumber=�� name=��>
<tradingaddress>
<line1></line1>
<line2></line2>
<line3></line3>
<postcode></postcode>
<region></region >
<country></country>
</tradingaddress>
<legaladdress>
<line1></line1>
<line2></line2>
<line3></line3>
<postcode></postcode>
<region></region >
<country></country>
</legaladdress>
</agent>
</agents>

Write a Servlet using Java 1.3.x (but NOT Java 1.4) to read an xml file from the virtual directory /test and validate it as follows:
The Servlet should be called TestParser
the filename is passed in the parameter xmlfile using the post method
e.g xmlfile will have a value of file1.xml
the file must be validated against the XML Schema � any validation errors should be EMAILED from the server to the account abd@rediff.net, the from address should be abc@rediff.net, the subject should be �XML Parser Error in File: �+filename
The body should contain details of the error, including the line at which the error occurred and the XML file that failed to validate should be attached to the email.

Next question
Write a Servlet using Java 1.3.x (but NOT Java 1.4) called DBTable to do the following:
The Database name will be supplied in the parameter dbname � this will be passed using either the Get or Post methods so your servlet should cater for both
Check for the existence of the MySQL database table agents and if it exists, delete it
Create a MySQL Database table as follows:
table name:agents
field:iatanonumeric
field:trline1alphanumeric
field:trline2alphanumeric
field:trline3alphanumeric
field:trline4alphanumeric
field:trpostcodealphanumeric
field:trregionalphanumeric
field:trcountryalphanumeric
field:lgline1alphanumeric
field:lgline2alphanumeric
field:lgline3alphanumeric
field:lgline4alphanumeric
field:lgpostcodealphanumeric
field:lgregionalphanumeric
field:lgcountryalphanumeric
If the Servlet encounters any errors it should email details of the errors, including a complete stack trace as follows:
EMAILED from the server to the account abd@rediff.net, the from address should be abc@rediff.net, the subject should be �Table Creation Failed�
The body should contain a summary of the error.
The stack trace should be attached to the email as an ASCII text file.

Next question
Write a Servlet using Java 1.3.x (but NOT Java 1.4) to parse a validated XML file from the virtual directory /test and insert it into the database created in Question 8.
The table should not allow duplicates � and should reject only the duplicate entries � continuing to insert the valid entries.
All errors including duplicate entries should be emailed as follows:
EMAILED from the server to the account abd@rediff.net, the from address should be abc@rediff.net, the subject should be �
Agent Insert Failed�
The body should contain the following information:
Records Loaded: xx
Records Rejected: yy
(where xx and yy are the number of errors)
An xml files should be attached to the email as follows which should be of the following format:
<rejectedrecords>
<rejected>
<recordno>xx</recordno>note xx is the record no in the original file
<agent iatanumber=�� name=��>
<tradingaddress>
<line1></line1>
<line2></line2>
<line3></line3>
<postcode></postcode>
<region></region >
<country></country>
</tradingaddress>
<legaladdress>
<line1></line1>
<line2></line2>
<line3></line3>
<postcode></postcode>
<region></region >
<country></country>
</legaladdress>
</agent>
<reason>
the reason the record was rejected, this may include any
Java exception description
</reason>
</rejected>
</rejectedrecords>
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
Hmmm, sounds like a school programming project. Your servlet will need to invoke an XML parser (SAX, DOM, JDOM, etc.). Good luck with the project!


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to I use servlets with xml