aspose file tools*
The moose likes Servlets and the fly likes RequestDispatcher problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher problem" Watch "RequestDispatcher problem" New topic
Author

RequestDispatcher problem

D Wynn
Ranch Hand

Joined: May 03, 2004
Posts: 38
Hi--
I using this code but for what ever reason I can't find my servlet class.....any ideas

if (userReq.equals("ULD INFO"))
{
stmt.close();
// String infoUrl = SERVLET_URL + ULD_YARD_MAN_PACKAGE + "YardManScanInfoDvr";
String infoUrl = ULD_YARD_MAN_PACKAGE + "YardManScanInfoDvr";
infoUrl += "?uldNum=" + URLEncoder.encode(inputArr[2]);
infoUrl += "&fromModule=" + URLEncoder.encode("YardManScanMain");
infoUrl += "&sessionStatus=" + URLEncoder.encode(sessionStatus);
// RequestDispatcher rd = req.getRequestDispatcher(infoUrl);
RequestDispatcher rd = req.getRequestDispatcher("/servlet/" + infoUrl);
if (rd != null)
{
rd.include(req, res);
userReq = "FINISHED";
}
else
{
// out.println("RequestDispatcher Error" + "<BR>");
infoUrl += "&scanLoc=" + URLEncoder.encode(inputArr[4]);
infoUrl += "&sortPhase=" + URLEncoder.encode(inputArr[5]);
infoUrl += "&area=" + URLEncoder.encode(inputArr[1]);
if (!(inputArr[6].equals("")))
infoUrl += "&action=" + URLEncoder.encode(inputArr[6]);
if (!(inputArr[7].equals("")))
infoUrl += "&destArea=" + URLEncoder.encode(inputArr[7]);
if (!(inputArr[21].equals("")))
infoUrl += "&loginUrl=" + URLEncoder.encode(inputArr[21]);
res.sendRedirect(SERVLET_URL + infoUrl);
// res.sendRedirect(infoUrl);
}
}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Have you looked between the couch cushions?

How is your servlet mapped in the deployment descriptor?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
D Wynn
Ranch Hand

Joined: May 03, 2004
Posts: 38
I'm not using deployment descriptors...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Originally posted by D Wynn:
I'm not using deployment descriptors...


Well then, I guess we've identified the problem.

You are, perhaps, trying to use the appropriately-maligned, sneered-at and probably disabled Invoker?
[ November 01, 2006: Message edited by: Bear Bibeault ]
D Wynn
Ranch Hand

Joined: May 03, 2004
Posts: 38
How do I correct it?
D Wynn
Ranch Hand

Joined: May 03, 2004
Posts: 38
And how is the Invoker disabled?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Originally posted by D Wynn:
How do I correct it?


Create a deployment descriptor in order to declare and map your servlets.
D Wynn
Ranch Hand

Joined: May 03, 2004
Posts: 38
There is no other way to do it...because none other my servlets use deployment descriptors
sven studde
Ranch Hand

Joined: Sep 26, 2006
Posts: 148
Read all about it here:

http://faq.javaranch.com/view?InvokerServlet

One question I have is about this part:

Order of elements in web.xml is very important...make sure all your <servlet> tags are declared before your <servlet-mapping> tags. You'll maybe want to keep the 'couplets' together, because it will be easier to see which one belongs to which, but don't do it!


With tomcat, keeping the <servlet> and <servlet-mapping> tags together like this:


instead of putting all the <servlet> tags first seems to work. Why should all the <servlet> tags go first? I happen to notice that on p.587 of HF Servlets & JSP, there is a DD where the pairs are kept together rather than putting all the <servlet> tags first. Inquiring minds want to know.

none other my servlets use deployment descriptors

Then, I think what Bear is saying is: you are doing everything all wrong.

[ November 01, 2006: Message edited by: sven studde ]

[ November 01, 2006: Message edited by: sven studde ]

[ November 01, 2006: Message edited by: sven studde ]
[ November 01, 2006: Message edited by: sven studde ]
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
sven - that link about the invoker servlet refers to the servlet 2.3 spec. In the 2.3 spec, order of elements is important, because the syntax of web.xml is specified via a dtd. with the servlet 2.4 spec, web.xml syntax is now specified via an xsd schema, and as a result the order of elements doesn't matter.

So, to answer your question, HF Servlets & JSP is about the 2.4 spec, so they can order the elements as they see fit.

Hope that helps.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Originally posted by sven studde:
Then, I think what Bear is saying is: you are doing everything all wrong.


Nothing quite so crass, but I am waiting for an explanation as to "why?" when a deployment descriptor is the best and accepted means to map servlets.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatcher problem