Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpServletRequest API

 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm trying to work on a small eCommerce application (Just like shopping cart). My controller should be able select different helper classes to perform different actions like authentication etc. I was going through PetStore application at Pet Store - Front Controller for my application.

My question is assuming view1, view2, view3 .... view n all these views call/being selected by only one controller. How can we find which view is calling the controller, in our controller code, so that we can use some if else kind of logic to select our own workflow .
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Front Controller pattern given in PetStore application, there is a method call request.getPathInfo(), in doGet() method. I tried the same method call. But evertime I invoke, it is always returning me null. What does that method do?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is a method call request.getPathInfo(), in doGet() method. I tried the same method call. But evertime I invoke, it is always returning me null. What does that method do?


It only returns something if the URL has extra path info. The first paragraph of the javadocs explain (very briefly) what extra path info. Suppose you're accessing the URL

and the servlet is configured to listen to "myServlet", then "myBadaBing" is the extra path info. Playing around with different URLs will give you a feeling for it.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!