Reloading page on servlet response

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cli
    New Member
    • Dec 2007
    • 9

    Reloading page on servlet response

    Hi Guys,

    I have a servlet which determines if the user entered a valid captcha,
    If the captcha is correct the request is forwarded to another servlet which inputs the form data to a DB.
    if the captcha is incorrect a response is sent back to client to indicate the captcha has to be re-entered.

    When the captcha is incorrect... I can't figure out how to respond to the client without forcing a page refresh. I want the page the user was on to remain with all the form data inplace so all that has to be re-entered is the captcha and not all other form elements.

    I'm sure this has been asked before, but I can't find the response:-(
    Thanks in advance.
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Once I started using a web application framework (JSF, although I dabbled in Struts) I kissed the ground like the old pope. Much of the tedious code you write is handled by the framework. In this case, the captcha would raise an error and the page would be automatically sent back to the user with the form filled out as before and error messages next to the field(s) that failed validation.

    Just my opinion, so I'll throw it out there -- who programs web apps and does or doesn't use a framework? Why?

    Comment

    • Cli
      New Member
      • Dec 2007
      • 9

      #3
      Why I'm not using one... There was just too much to learn when I started this project.. Had only seen Spring in action and it scared me ;-)

      Can I do what I'm trying to do with out a framework?

      Anyone suggest a good framework, My app is heavily dependant on AJAX and DB access.

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Originally posted by Cli
        Why I'm not using one... There was just too much to learn when I started this project.. Had only seen Spring in action and it scared me ;-)

        Can I do what I'm trying to do with out a framework?

        Anyone suggest a good framework, My app is heavily dependant on AJAX and DB access.
        AJAX -- now that's scary. What fraemwork/toolkit are you using for it?

        I've used JSF, which is part of the J2EE. It does take time and has it's pluses and minuses. Struts has been around for a long time and has several offshoots, and Spring has its own web app framework, too. One of the joys/pains of Java is that there are so many choices.

        By the way, I've heard developers say the following many times: "I don't have time to learn a framework". They the realize they have to code up their own framework, which takes even longer. Learn to stand on the shoulder of those who have gone before you.

        In any case, keep your presentation separate from your database bck end -- there should be no mention of database access in your servlets/JSP.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          If you want to do it using AJAX then you should probably be asking in the Javascript/AJAX forum.
          With AJAX the page would not (appear to) be submitted at all so all the fields would have their original values.

          Comment

          • 6502kid
            New Member
            • Mar 2008
            • 6

            #6
            My re-worked version of the jcaptcha.jsp file should do what you want.

            I have a working example, that shows how to preserve all the input
            fields values on a refresh, or call and return to results page.

            http://jcaptcha.webreg istrationservic es.com/

            The jcaptcha.jsp and all example source available for download there.

            Comment

            Working...