Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config no working when use @WebServlet annotation #73

Closed
GoogleCodeExporter opened this issue Oct 13, 2015 · 6 comments
Closed

config no working when use @WebServlet annotation #73

GoogleCodeExporter opened this issue Oct 13, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link


 */
@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
Copy link
Author

Have you confirmed that the init() method is being called?

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

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

@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
Copy link
Author

Probably because you're using annotations now.

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

  • Changed state: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant