whbah / kaptcha

Automatically exported from code.google.com/p/kaptcha
Other
0 stars 0 forks source link

config no working when use @WebServlet annotation #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

 */
@WebServlet("/captcha.jpg")
public class MyCaptchaServlet extends KaptchaServlet {

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    public void init(ServletConfig servletconfig) throws ServletException {
        servletconfig.getServletContext().setInitParameter("kaptcha.textproducer.font.color", "red");
        super.init(servletconfig);
    }

}

then I request captcha.jpg in browser, the color is still black, no red.

Original issue reported on code.google.com by lcy.so...@gmail.com on 19 May 2014 at 1:59

GoogleCodeExporter commented 9 years ago
Have you confirmed that the init() method is being called?

Original comment by latch...@gmail.com on 20 May 2014 at 12:39

GoogleCodeExporter commented 9 years ago
Yes, adding a breakpoint to first line of init() method, and it is being called.

Original comment by lcy.so...@gmail.com on 20 May 2014 at 1:28

Attachments:

GoogleCodeExporter commented 9 years ago
Weird. I don't know. You're going to have to debug it. For some reason that 
setting isn't being set properly. The Kaptcha code isn't too complicated, so it 
shouldn't be too hard. Let us know when you figure it out. =)

Original comment by latch...@gmail.com on 20 May 2014 at 1:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
@WebServlet(urlPatterns = "/mycaptcha.jpg", 
initParams = { 
        @WebInitParam(name = "kaptcha.textproducer.font.color", value = "red"),
        @WebInitParam(name = "kaptcha.textproducer.char.length", value = "3")
})
public class MyCaptcha extends KaptchaServlet {

    private static final long serialVersionUID = 1L;

}

working well now with above code, but I don't know the reason of this issue.

Original comment by lcy.so...@gmail.com on 20 May 2014 at 6:22

Attachments:

GoogleCodeExporter commented 9 years ago
Probably because you're using annotations now.

Original comment by latch...@gmail.com on 20 May 2014 at 6:34