August 2005
Monthly Archive
Tue 30 Aug 2005
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);
Fri 26 Aug 2005
Posted by Frank Kim under
Miscellaneous1 Comment
To search for all files that contain a certain string use find with the -exec flag. For example:
find . -name "*.haystack" -type f -exec grep -l needle "{}" ";"
grep -l flag tells grep to output only the file name if there is a match.
"{}" is replaced iteratively by the file names found.
";" terminates the command.
Thu 25 Aug 2005
Posted by Frank Kim under
Page Development1 Comment
Putting parameters in the link.
Using back quotes you can embed Java code to extract the parameters and place them in the link. For example:
<a href="/foo.jhtml?`request.getParameter("bar")`">example</a>
To learn more, Using Back Quotes.
Tue 23 Aug 2005
Posted by Frank Kim under
JDBC ,
RepositoryNo Comments
Today I was trying to determine how to optimize the populating of a table. I was using ATG Relational Views which took 3.5 minutes to add 6000 lines to a table.
After googling for awhile I learned how to do this using JDBC directly and was able to do the same populating in 0.14 minutes. That’s quite a performance improvement.
It would be interesting to contract the performance differences using ATG’s repository implementation but right now I am developing on ATG 4.5.1 so I can’t.
These are the links to the sites I used to educate me on PreparedStatement’s and batching.
ONJava.com: An Introduction to JDBC, Part 3
JavaWorld.com: Overpower the Prepared Statement
PreciseJava.com: Best practices to improve performance in JDBC
DBA-oracle.com: Optimize Oracle INSERT performance
Thu 18 Aug 2005
The typical JHTML file is structured like this.
<importbean bean="/atg/dynamo/service/jdbc/RelationalViewDroplet">
<nucleus type=import>
/atg/dynamo/droplet/ForEach
/atg/dynamo/droplet/Switch
</nucleus>
<java type="import">
java.util.*
java.net.*
</java>
<java>
List ll = (List) request.resolveName("/betweengo/BigList");
</java>
Thu 18 Aug 2005
Posted by Frank Kim under
AdobeNo Comments
This is an article on how to speed up the excruciatingly slow Adobe Reader 6.
How to use liposuction to repair Adobe Reader 6
A probably better way than what is proposed in this article is to move all the unused plugins from the plug_ins directory to the Optional directory.
Or you could simply just upgrade to Adobe Reader 7, which is much faster. 
Wed 17 Aug 2005
Posted by Frank Kim under
Java SENo Comments
JavaWorld has a great article on finding a class’s runtime origin called Back to your Class roots. Below is the highly useful getClassLocation method from the article.
/**
* Given a Class object, attempts to find its .class location.
* Use for testing/debugging only.
*
* @return URL that points to the class definition; null if not found
*/
public static URL getClassLocation (final Class cls) {
if (cls == null) throw new IllegalArgumentException ("null input");
URL result = null;
final String clsAsResource = cls.getName ().replace ('.', '/').concat (".class");
final ProtectionDomain pd = cls.getProtectionDomain ();
// java.lang.Class contract does not specify if 'pd' can ever be
// null; it is not the case for Sun's implementations, but guard
// against null just in case:
if (pd != null) {
final CodeSource cs = pd.getCodeSource ();
// 'cs' can be null depending on the classloader behavior:
if (cs != null) result = cs.getLocation ();
if (result != null) {
// Convert a code source location into a full class file location
// for some common cases:
if ("file".equals (result.getProtocol ())) {
try {
if (result.toExternalForm ().endsWith (".jar") ||
result.toExternalForm ().endsWith (".zip"))
result = new URL ("jar:".concat (result.toExternalForm ())
.concat("!/").concat (clsAsResource));
else if (new File (result.getFile ()).isDirectory ())
result = new URL (result, clsAsResource);
}
catch (MalformedURLException ignore) {}
}
}
}
if (result == null) {
// Try to find 'cls' definition as a resource; this is not
// documented to be legal, but Sun's implementations seem to allow
// this:
final ClassLoader clsLoader = cls.getClassLoader ();
result = clsLoader != null ?
clsLoader.getResource (clsAsResource) :
ClassLoader.getSystemResource (clsAsResource);
}
return result;
}
Fri 12 Aug 2005
Posted by Frank Kim under
ACCNo Comments
If you cannot connect to a site using the ACC try the following.
- use the host name instead of the IP address
- check that you are using the correct RMI port
- telnet to the site using the RMI port and see if you can connect
- check the ACC output window to see if there were any exceptions. if there was an
UnknownHostException then try adding the host to your hosts file to fix the problem
Note: The host name you use should be the same as the java.rmi.server.hostname Java argument that is set in the server’s postEnvironment.sh.
JAVA_ARGS="${JAVA_ARGS} -Djava.rmi.server.hostname=kimcityqa"
Thu 11 Aug 2005
Often during development of an ATG J2EE application one will suddenly run into a 404 error. 404 means that the server could not locate the requested page . But often when one sees this error it is not because ATG could not locate the requested page but because it could not generate the page due to some sort of error which unfortunately ATG sometimes does not log. The error could be one of several.
- The J2EE application that contains the page did not properly start or was not started at all. One can check if the application was started either by looking in the ACC under the J2EE Deployment Editor or checking in the
dynamo.log if the application was started and/or listed in the list of modules at start up.
- A runtime exception occurred in one of the droplets that were invoked in the page. Unfortunately ATG does not log the runtime exception, it is swallowed up somewhere. The best way to debug this is to start removing parts of the JSP page until you discover which part of the page is causing the 404.
Wed 10 Aug 2005
Posted by Frank Kim under
Windows1 Comment
On Windows you can manually match hostnames to IP addresses using the hosts file located in C:\WINDOWS\system32\drivers\etc. An example of a hosts file:
127.0.0.1 localhost
#10.22.1.18 foo foo.bar.ca
16.17.18.19 toronto
16.17.18.125 boston
If you find that the contents of the hosts file are not being picked up by Windows it might be because the file is corrupted though the corruption is not evident in your editor. The best thing to do is to delete or move that file and create a brand new hosts file and hopefully the contents of this hosts file will be picked up by Windows.
Next Page »