Is XML - SERVLET Communication possible ?


Web tier: servlets, JSP, Web frameworks: Is XML - SERVLET Communication possible ?

  1. Is XML - SERVLET Communication possible ? (1 messages)

    Hi All,

    Anybody please tell me is xml - servlet communication possible if yes then how to communicate xml and servlet each other. ?

    I have to make a program in which servlet will call xml attribute and print the xml attribute .

    following is the servlet file..

    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;

    public class XmlServletCommunicaiton extends HttpServlet {

        public void doGet(HttpServletRequest request,
                          HttpServletResponse response)
            throws IOException, ServletException
            PrintWriter out = response.getWriter();


        public void doPost(HttpServletRequest request,
                          HttpServletResponse response)
            throws IOException, ServletException
            doGet(request, response);



    following is xml file ..


    <?xml version="1.0"?>
    <!DOCTYPE PARTS SYSTEM "parts.dtd">
    <?xml-stylesheet type="text/css" href="xmlpartsstyle.css"?>
       <TITLE>Computer Parts</TITLE>
          <COST> 123.00</COST>
          <ITEM>Video Card</ITEM>
          <MODEL>All-in-Wonder Pro</MODEL>
          <COST> 160.00</COST>
          <ITEM>Sound Card</ITEM>
          <MANUFACTURER>Creative Labs</MANUFACTURER>
          <MODEL>Sound Blaster Live</MODEL>
          <COST> 80.00</COST>
          <ITEM>inch Monitor</ITEM>
          <MODEL> 995E</MODEL>
          <COST> 290.00</COST>


    And I have to retrieve say <ITEM>Video Card</ITEM> in servlet.

    So please tell me how to do that

    Please help.

    Please reply with coding ...


    Threaded Messages (1)

  2. XML Parser[ Go to top ]

    hehe you need to use a XML parser. read the XML in and then parse for that node. Then you can do what ever you want with it. I wouldn't call this XML-Servlet communication though. It's more like a Servlet handling a HTTPRequest of XML content.

    Why not just do Web Services.