Topic
1 reply Latest Post - ‏2012-05-25T03:11:42Z by Maddy_tryingtobesmarl
javaxml
javaxml
1 Post
ACCEPTED ANSWER

Pinned topic Parsing xml using java servlets

‏2011-12-12T13:04:49Z |
Hello
I want to implement a basic login mechanism using java servlet and xml schema.
XML file

<?xml version="1.0"?>
<students>
<student>
<name>John</name>
<grade>B</grade>
<age>12</age>
</student>
<student>
<name>Mary</name>
<grade>A</grade>
<age>11</age>
</student>
<student>
<name>Simon</name>
<grade>A</grade>
<age>18</age>
</student>
</students>

I want to write a servlet which reads the values and from the xml file and accepts POST requests from a login form(typically username and password).

FORM:
<form action="" method="post" >
<table border="1" align="center">
<tr>
<td>Username:</td>
<td><input type="text" id="username"></td>
</tr>

<tr>
<td>Password:</td>
<td><input type="password" id="password"></td>

</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" id="sub" value="Submit"></td>

<tr>

</table>
</form>
Can someone guide me over this.??

Regards
Updated on 2012-05-25T03:11:42Z at 2012-05-25T03:11:42Z by Maddy_tryingtobesmarl
  • Maddy_tryingtobesmarl
    1 Post
    ACCEPTED ANSWER

    Re: Parsing xml using java servlets

    ‏2012-05-25T03:11:42Z  in response to javaxml
    Hi,

    All you can do is submit to a servlet that is mapped in web.xml file.

    Then in the servlet java file use JAXP DOM API to read/write the xml file.

    PFA the customerservice which parses a customer.xml file

    Regards,
    Maddy