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.io.*;
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
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Hello");
}
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"?>
<PARTS>
<TITLE>Computer Parts</TITLE>
<PART>
<ITEM>Motherboard</ITEM>
<MANUFACTURER>ASUS</MANUFACTURER>
<MODEL>P3B-F</MODEL>
<COST> 123.00</COST>
</PART>
<PART>
<ITEM>Video Card</ITEM>
<MANUFACTURER>ATI</MANUFACTURER>
<MODEL>All-in-Wonder Pro</MODEL>
<COST> 160.00</COST>
</PART>
<PART>
<ITEM>Sound Card</ITEM>
<MANUFACTURER>Creative Labs</MANUFACTURER>
<MODEL>Sound Blaster Live</MODEL>
<COST> 80.00</COST>
</PART>
<PART>
<ITEM>inch Monitor</ITEM>
<MANUFACTURER>LG Electronics</MANUFACTURER>
<MODEL> 995E</MODEL>
<COST> 290.00</COST>
</PART>
</PARTS>
--------------------
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 ...
Thanks
-
Is XML - SERVLET Communication possible ? (1 messages)
- Posted by: harish pathak
- Posted on: February 10 2006 06:39 EST
Threaded Messages (1)
- XML Parser by Sheng Sheen on March 02 2006 19:23 EST
-
XML Parser[ Go to top ]
- Posted by: Sheng Sheen
- Posted on: March 02 2006 19:23 EST
- in response to harish pathak
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.