Source Code : Send XML
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Send XML
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ResourceServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//get web.xml for display by a servlet
String file = "/WEB-INF/web.xml";
URL url = null;
URLConnection urlConn = null;
PrintWriter out = null;
BufferedInputStream buf = null;
try {
out = response.getWriter();
url = getServletContext().getResource(file);
//set response header
response.setContentType("text/xml");
urlConn = url.openConnection();
//establish connection with URL presenting web.xml
urlConn.connect();
buf = new BufferedInputStream(urlConn.getInputStream());
int readBytes = 0;
while ((readBytes = buf.read()) != -1)
out.write(readBytes);
} catch (MalformedURLException mue) {
throw new ServletException(mue.getMessage());
} catch (IOException ioe) {
throw new ServletException(ioe.getMessage());
} finally {
if (out != null)
out.close();
if (buf != null)
buf.close();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
Thank with us