• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt in filters concept

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

/* this is my servlet program ****/

[ August 18, 2008: Message edited by: yuvraj kotegar ]
[ August 27, 2008: Message edited by: yuvraj kotegar ]
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
/***********this is my web.xml content**************/


/***** i have skipped the web-app tag**********/

[ August 18, 2008: Message edited by: yuvraj kotegar ]
[ August 27, 2008: Message edited by: yuvraj kotegar ]
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
package webcert.ch03.ex0304;

import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class MicroPaymentFilter implements Filter {

public void init(FilterConfig config) throws ServletException {
}

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {

HttpServletRequestWrapper reqWrapper = new HttpServletRequestWrapper(
(HttpServletRequest) request);
String referrerName = reqWrapper.getPathInfo().substring(1);

if (referrerName != null) {
System.out.println("Micropayment made to " + referrerName);
reqWrapper.setAttribute("referrer", referrerName);
}
chain.doFilter(reqWrapper, response);
PrintWriter out = response.getWriter();
out.write("<BR >0.0001c has been paid to referrer " + referrerName</BR> ;
}

public void destroy() {
}

}


/??? this is my filter code???/
[ August 18, 2008: Message edited by: yuvraj kotegar ]
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thing is i will be accessing the Micropayment servlet class from the URl i pass in request!!!

example

http://localhost:8080/ex0304/Micropayment/David

how will it access the filter class i wrote??
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my doubt is how does the filter class i wrote get invoked ?? here in this case it is MicroPaymentFilter.

because in
MicroPaymentServlet class am not calling the filter class in anyway!!!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on beginning Java.

For more information, please read this.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by yuvraj kotegar:
my doubt is how does the filter class i wrote get invoked?

The container invokes the filter as configured in the deployment descriptor.

Perhaps this tutorial will help.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply

the response back to the client is given by my Filter class or the class i invoked??

like in this case is it MicroPaymentServlet or MicroPaymentFilter??
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whichever writes to the response.

Please review proper use of the code tags.
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic