JSP is really a cool extension of
HTML. I think the most common way to interact with a servlet via a JSP is to use the HTML
<form> tag. I have managed to successfully create a connection to the servlet via a standard Java application. The thing I completely overlooked was that the xml request that I was sending had to be sent in
URL encoding. If anyone’s interested, this is who I've done it:
URL service = new URL("http://localhost:8080/52nSOSv2/sos");
URLConnection connection = service.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
String request = URLEncoder.encode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<GetObservation service=\"SOS\" version=\"0.0.31\" " +
"xmlns=\"http://www.opengeospatial.net/sos\" " +
"xmlns:gml=\"http://www.opengis.net/gml\" " +
"xmlns:ogc=\"http://www.opengis.net/ogc\" " +
"xmlns:ows=\"http://www.opengeospatial.net/ows\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:swe=\"http://www.opengis.net/swe\">" +
"<offering>TAG_READING</offering>" +
"<eventTime>" +
"<ogc:During>" +
"<gml:TimePeriod>" +
"<gml:beginPosition>2001-12-10T08:00:00</gml:beginPosition>" +
"<gml:endPosition>2008-12-13T12:00:00</gml:endPosition>" +
"</gml:TimePeriod>" +
"</ogc:During>" +
"</eventTime>" +
"<procedure>urn:ogc:def:procedure:wavertrend_rx201_sensory_web</procedure>" +
"<observedProperty>urn:ogc:def:phenomenon:OGC:1.0.30:temperature</observedProperty>" +
"<featureOfInterest>" +
"<ObjectID>COR01</ObjectID>" +
"</featureOfInterest>" +
"<resultFormat>text/xml;subtype=\"OM\"</resultFormat>" +
"</GetObservation>", "UTF-8");
System.out.println(request);
out.writeBytes(request);
out.flush();
out.close();
DataInputStream in = new DataInputStream(connection.getInputStream());
String line = "";
System.out.println("Response!!");
while ((line = in.readLine()) != null)
System.out.println(line);
This site was rather useful:
http://www.javaworld.com/javaworld/j...javatip34.html
The guy there said that the HTTP request's "content-type" field to be "application/x-www-form-urlencoded" because it is necessary since some versions of Netscape's browser has a bug which does not give out this proper content type when doing POSTs.
I think it would have been better if I just read in the xml request from a file - that's what I think I'll try to do now

Oh and the URL:
http://localhost:8080/52nSOSv2/sos specifies the URL to the servlet as defined in the web.xml of any servlet driven website.