// Create query string
String queryString = "param1=" +
URLEncoder.encode(param1Value, "UTF-8");
queryString += "¶m2=" +
URLEncoder.encode(param2Value, "UTF-8");
// Make connection
URL url = new URL("http://www.obiweb.com.au"+queryString);
URLConnection urlConnection = url.openConnection();
// Read the response
BufferedReader in = new BufferedReader(
new InputStreamReader(urlConnection.getInputStream()));
String line = null;
while ((line = in.readLine()) != null)
{
System.out.println(line);
}
in.close();
written by objects
\\ tags: GET, query string, request, url, URLConnection
When using DWR you sometimes need access to the servlet request or the session.
When you do you can get access to them via the DWR WebContext class as shown in the following example code.
WebContext ctx = WebContextFactory.get();
HttpServletRequest request = ctx.getHttpServletRequest();
written by objects
\\ tags: dwr, request, servlet, session
When using JTST to access a request parameter we typically use something like this:
${param.xyz}
If the parameter name contains a . then this becomes
${param.xyz.abc}
Problem is that JSTL interprets this as being the abc property of the xyz bean which is not what we want.
In this case we instead need to use the more long winded JSTL syntax for specifying the property name of interest:
${param['xyz.abc']}
This now correctly returns the value of the request paramater with name ‘xyz.abc’.
written by objects
\\ tags: jstl, param, parameter, request, syntax