hi craig! perhaps you misunderstood. you do not have to map any JSP inside the web.xml! it is only required for Servlets (and this is necessary anyway, front controller or not) the logical/physical mapping is something I am doing inside the database where I am also keeping the privileges. as my app requires fine grained access control (each ressource may be accessed by certain users from certain machines) the additional mapping is not much additional pain. in fact, if there is no physical URL specified in the database I just use the logical one. I do this for all servlets (so the logical URL in the database is just the same as the one in web.xml and there is no physical URL specified) consider this more detailed example:
1) for SERVLETS (residing in the usual directory(i.e. package) structure in WEB-INF/classes) <servlet-mapping> <servlet-name>Login</servlet-name> <url-pattern>/WEB-INF/login</url-pattern> </servlet-mapping> in the database (in my "privileges" record for this ressource, only the 2 interesting fields) LogicalURL | RealURL /login | (null) i.e. so just the one entry in the database I have to do anyway. 2) JSP's (which reside in WEB-INF/jsp) in the database (in my "privileges" record for this ressource, only the 2 interesting fields) LogicalURL | RealURL /top | /jsp/top.jsp and **NOTHING** in web.xml inside the front controller servlet code: (// note: defUrl[i] contains RealURL if specified, LogicalURL otherwise!!) durl = "/WEB-INF"+defUrl[i]; rd = scon.getRequestDispatcher(durl); // scon holds ref. to servlet context (...etc...) so, if you have 100's of JSP's, consider using the above approach of retrieving their URLs from a database (which is more administrable than mappings in web.xml) the mapping LogicalURL->RealURL is optional! servlet mappings only have to be specified once in web.xml (and *only* there if you do not intend to do any mapping and individual access control) just as always, only use a mapping URL behind WEB-INF. btw, the mapping from logical to physical is an additional proposition in the front controller pattern as specified on java.sun.com hope this clears things up & helps! greetings > Ah, this is an interesting response. I had not contemplated the fact that > you would need to list all of the JSPs/Servlets that you wanted to forward > to inside the web.xml file. I guess since they are in the WEB-INF > directory, > I assumed all rules were off (just like security is)! > > Doesn't this seem like double work to anyone? You would have to maintain > an > internal list of page mappings and also another list in the web.xml file. > What a pain! I had hoped you could just forward to the resource directly > based on the path without going through the whole web.xml mapping stuff. > > I am a little put off by this approach now, if the web.xml file needs to > be > involved. We have 100s of JSP pages - I do not want to have to map them > all > twice. Surely the JCP team could spec a different way of doing it in the > future ... > > Thanks, > Craig > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 04, 2002 10:13 PM > To: JDJList > Subject: [jdjlist] Re: Issue with servlet forwarding on WLS 7 > > > hi craig! > I implemented a front controller servlet like this in tomcat and put my > jsp's and servlets > behind the WEB-INF directory (*without* being aware of the suggestion in > the > J2EE patterns book. I just found it quite sensible to put it there - it's > in > the context of the > current webapp but still hidden from the client) > > cosnippet: > // note: > // defUrl is of type String[] and contains values retreived from a > database > // where logical URLs are mapped to physical ones, i.e. to the client > // it is transparent wether the requested resource is a servlet or a JSP > // e.g. logical URL -> physical URL (in defUrl[] array) > // "/login" -> "/login" ... servlet URL, see > below > // "/top" -> "/jsp/top.jsp" ... path to JSP file > residing in the directory "/WEB-INF/jsp/" > // the file "web.xml" contains e.g. the following: > // <servlet-mapping> > // <servlet-name>Login</servlet-name> > // <url-pattern>/WEB-INF/login</url-pattern> > // </servlet-mapping> > > > > durl = "/WEB-INF"+defUrl[i]; > rd = scon.getRequestDispatcher(durl); // scon holds ref. to servlet > context > rd.forward(request,response); > > > > works like a charm. as it seems, you are trying exactly the same (as far > as > I can see) and it works also for servlets (which are referenced by the > url-pattern of the servlet mapping in web.xml) > if your configuration does not differ I can only assume that this is a > limitation of weblogic. > if so, I do not find this very favourable, because then it is quite > difficult to implement the front controller pattern in a sensible way > which > is > portable across different application servers and/or servlet containers. > please let me know if you should find out that weblogic behaves in fact > differently and - if yes - > wether this seems standards conformant (otherwise tomcat's behaviour is, > and > tomcat is known to be the reference implementation for servlet & JSP > specs) > if I get around to it, I will try to find out what the specs say about > this. > greetings > > > Hi, > > > > I have a war file deployed on Weblogic 7. I have placed all of my jsp > > files > > under /WEB-INF/jsp as a security measure to control direct client access > > to > > the JSPs. All client access is via a front controller servlet, which > > redirects to a particular JSP based on criteria in the request. My > problem > > is if I make a call something like this inside the controller servlet: > > > > ... > > > > dispatcher = context.getRequestDispatcher("/WEB-INF/jsp/my.jsp"); > > > > dispatcher.forward(request, response); > > > > ... > > > > I get a 404 resource not found returned to the client. This should be > > really > > simple, so I am frustrated with this! What am I missing? This structure > is > > detailed in the J2EE patterns book, but after going back and looking at > > the > > section again I realize there is a lot of hand waving and no code > examples > > for this particular part. If I drop the leading slash from the path I > get > > a > > NullPointerException, which according to the JavaDocs is the correct > > functionality - it explicitly states the path must begin with a slash > and > > represents the path from the root of current context to the required > > JSP/servlet. > > > > I haven't had a chance to try this on another container yet, so perhaps > > this > > is a Weblogic quirk. Also as soon as I post this I am going to try and > > move > > the JSPs out from under the WEB-INF directory just to verify what the > > problem really is (ie. all forwarding is not working, or just forwarding > > to > > resources under WEB-INF). Of course having the JSPs out from under > WEB-INF > > defeats the purpose of this exercise in the long run! > > > > Thanks, > > > > Craig > > > > > > > > ____________________________________________________ > > To change your JDJList options, please visit: > > http://www.sys-con.com/java/list.cfm > > > > Be respectful! Clean up your posts before replying > > ____________________________________________________ > > > > -- > +++ GMX - Mail, Messaging & more http://www.gmx.net +++ > NEU: Mit GMX ins Internet. G�nstige DSL- & Modem/ISDN-Tarife! > > > ____________________________________________________ > To change your JDJList options, please visit: > http://www.sys-con.com/java/list.cfm > > Be respectful! Clean up your posts before replying > ____________________________________________________ > > ____________________________________________________ > To change your JDJList options, please visit: > http://www.sys-con.com/java/list.cfm > > Be respectful! Clean up your posts before replying > ____________________________________________________ > -- +++ GMX - Mail, Messaging & more http://www.gmx.net +++ NEU: Mit GMX ins Internet. Rund um die Uhr f�r 1 ct/ Min. surfen! ____________________________________________________ To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm Be respectful! Clean up your posts before replying ____________________________________________________
