Re: [ginp-users] ginp issues
Brought to you by:
burchbri,
dougculnane
From: Gleb S. <gl...@ma...> - 2005-02-28 19:34:56
|
Hi guys, Here is Russian resources file and some more comments... In GinpEnv constructor you do: public GinpEnv(HttpServletRequest req) throws MalformedURLException { String reqUrl=req.getRequestURL().toString(); String cPath=req.getContextPath(); String rootUrl=reqUrl.substring(0,reqUrl.indexOf(cPath)+cPath.length()); if (rootUrl.indexOf(cPath)<=0) { rootUrl+=cPath; } this.url=new URL(rootUrl); } Imagine that web application is configured without specific context path, then cPath is "" and => rootUrl gets "" too => MalformedURLException Consider something like: public GinpEnv(HttpServletRequest req) throws MalformedURLException { StringBuffer basePath = new StringBuffer(); basePath.append(req.getScheme()).append("://").append(req.getServerName()); int iPort = req.getServerPort(); //do not append generic HTTP ports if ((iPort != 80) && (iPort != 443)) { basePath.append(":").append(iPort); } basePath.append(req.getContextPath()); String rootUrl = basePath.toString(); System.out.println("rootUrl: " + rootUrl); this.url = new URL(rootUrl); } And one more time, please consider adding two classes implementing Struts Action interface. At least GalleryAction and PictureAction with content similar to your servlets classes and forwards in correct places would completely decouple ginp from any hardcoded locations without any config changes...(for Struts users only though). So it would be possible to use ginp as a jar library completely flexible to existing app. Thanks for your work, Gleb |