This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, It would be of good help if you can enlighten me about a process to resolve this problem, mentioned below. The Problem : as explained here .. (i) My application has a dispatcher servlet which acts as controller (of my app's MVC framework). (ii) I have mapped URI accordingly in web.xml for this servlet. That looks like - <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>com.control.MyControlProcessor</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/servlet/MyServlet</url-pattern> </servlet-mapping> (iii) In accordance with URI mapping, my servlet gets invoked while I send a request at http://myhost/myapp/servlet/MyServlet (So far, things happen as it is required) (iv) Next, I need to ask the user to pass the Database alias too in URL where he would like to get connected through my app. Lets assume he would like to get connected to DB 'MyDB', thus he would be required to mention this alias as a part of URL (not as a parameter). It would look like http://myhost/myapp/servlet/MyServlet/MyDB [ this part can not be changed cause this deals with a security specs for my application ] Here, weblogic 6.1 (and only weblogic) creates problem. It tries to accept the URL as is and look for sending a response for the requested URL and ends up with a 404 error [page not found]. Work outs in JBoss 3.0 and Resin 2.1.9 yes, the design also creates problem with resin or JBoss. Though, I have solved it with few minor changes in web.xml. root-cause .. As it appears, the dispatching logic for requests needs to be taken care of by MyServlet and it is already happening there. Hence, I assumed, the root of problem is, the servlet container of application server never releases the control to MyServlet to take care of the URI parsing and Request fetching. I tried with a mapping in web.xml. which looks like - <servlet> <servlet-name>invoker</servlet-name> <servlet-class>com.caucho...ServletInvoker</servlet-class> </servlet> <servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> This seems to be working perfectly for resin and JBoss. Probably, the servlet-invoker does the trick here. It passes the control completely to MyServlet for rest of the dispatching part. In Weblogic, I am not being able to achieve this. (1) I really dont know which servlet-class in its package (weblogic.*) can help me to achive this. (Couldn't get any clue in its API too). (2) I am required to know whether there is any existing configuration which can be used to invoke my servlet dispatcher through WL's ServletInvoker ? (3) How would I be able to turn on this default configuration (if it is atall there) ? Thanks in advance,
Personally, I'd recommend not playing tricks with the URL. As you've seen, it's not all that reliable. I'm afraid that insofar as your example is only showing an attempt at acquiring one resource of what is presumably a larger system, I can't really offer a whole lot in the way of possible cleaner alternatives. If you have a limited number of datasources to connect, however, the quickest solution is probably to set up servlet mappings for each "path", make them all point back to the master servet, and let it decode the URL for more info.
An IDE is no substitute for an Intelligent Developer.
Joined: May 27, 2003
Thanks for the reply Tim. I understand what you are saying. Though, the problem is, the datasource configuration is being treated as a different part in this application. This is actually a floating part and kept outside of the scope of package. So the host can add/remove as many DataSources as he wants for this application without modifying the package. Thus, the application binary (the whole package I mean) would not be knowing its number of datasources at the time of packaging. It would be of great help if you can figure out a way to resolve this.