This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher problem

 
D Wynn
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked between the couch cushions?

How is your servlet mapped in the deployment descriptor?
 
D Wynn
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not using deployment descriptors...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I correct it?
 
D Wynn
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And how is the Invoker disabled?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no other way to do it...because none other my servlets use deployment descriptors
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic