Programming


In one of our ATG servlet’s we were making a normal HTTP call to a page located on our ATG Dynamo server.

url = new URL(urlString);
connection = (HttpURLConnection)url.openConnection();
reader = new InputStreamReader(connection.getInputStream());

However when trying to get the input stream we got a FileNotFoundException yet we were able to go to the same URL using a browser. Googling around we found this lovely thread about the same problem.

To summarize the thread, the problem was in our proxy settings which are set on Windows in localconfig/environment.bat and on UNIX in localconfig/environment.sh. An example of proxy settings on Windows is set PROXY_ARGS=-Dhttp.proxyHost=192.168.1.134 -Dhttp.proxyPort=8080.

The proxy server did not recognize our machines as valid clients so it rejected our requests. Once we changed the proxyHost argument to point to a valid server then this problem was fixed.

In JHTML pages, the request object is of class DynamoHttpServletRequest which has many methods that are not part of the HttpServletRequest interface including the very useful resolveName method for looking up components in Nucleus.

In JSP pages on ATG there is no guarantee that the request object is of class DynamoHttpServletRequest. According to the JSP specification the request object always implements the HttpServletRequest interface.

If you need to get the DynamoHttpServletRequest do something like this:

DynamoHttpServletRequest dynRequest  = atg.servlet.ServletUtil.getDynamoRequest(request);

If you need to get a PortalServletRequest do something like this:

PortalServletRequest portalRequest = (PortalServletRequest) request.getAttribute(atg.portal.servlet.Attributes.PORTALSERVLETREQUEST);