www.webdeveloper.com
Results 1 to 10 of 10

Thread: Refresh the jsp file not the whole page

  1. #1
    Join Date
    Jul 2012
    Posts
    7

    Refresh the jsp file not the whole page

    <%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
    <%
    String error=request.getParameter("error");
    if(error==null || error=="null"){
    error="";
    }
    %>

    <html>
    <head>
    <title>Captcha</title>
    <script>
    function validate()
    {
    alert("Captcha empty");
    document.frmLogin.usrValue.focus();
    return false;
    }

    function refresh()
    {
    window.location='vcaptcha.jsp';
    }
    </script>
    </head>

    <body>
    <div><%=error%></div>
    <form name="frmLogin" onSubmit="return validate();" onReset="return refresh();" method="post">
    <div id ="imageCaptcha">

    <img src = "vcaptcha.jsp">

    </div>
    <br />
    <br />
    Captcha Code <input type="text" name="usrValue" /><br />
    <br />
    <input type="submit" name="Submit" value="Submit" />
    <input type="reset" name="Refresh" value="Refresh">
    </form>
    </body>
    </html>

    this is my code i m working on... file name is login.jsp having another file vcaptcha.jsp i want when the user click on refresh button only the captcha made by vcaptcha.jsp is refreshed not the whole page.. i have not much idea abt jsp and javascript... so please hell me out in this matter..

  2. #2
    Join Date
    Mar 2012
    Posts
    202
    HTML Code:
    <img src = "vcaptcha.jsp" ID="captcha">
    Code:
    function refresh()
    {
    document.getElementById("captcha").src='vcaptcha.jsp?'+(new Date().getTime());
    }
    I hope this helps?

  3. #3
    Join Date
    Jul 2012
    Posts
    7
    Thanks alot buddy... how better i m feeling today...

    Now i m going to tell u my real problem as i have a hope u can help me out...

    i have to build a captcha with both visual and audio captcha i m able to made visual captcha but not audio captcha with the help of vcaptcha.jsp i m able to generate image jpeg nd nw i have to create audio captcha.. i m thinking that random string is generated like 3rStAd then when i move my mouse on speaker image it speak "number three lowercase r uppercase S lowercase t uppercase A and finally lowercase d"

    i have no idea about jsp, php... but i have seen this page.. http://www.nswardh.com/shout/ i also want to create audio captcha is like this...

    due to ur help my code becomes this now..
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
    <%
    String error=request.getParameter("error");
    if(error==null || error=="null"){
    error="";
    }
    %>

    <html>

    <head>

    <title>Captcha</title>

    <script>
    function validate()
    {
    alert("Captcha empty");
    document.frmLogin.usrValue.focus();
    return false;
    }
    function refresh()
    {
    document.getElementById("captcha").src='vcaptcha.jsp?'+(new Date().getTime());
    }

    </script>

    <script language="javascript" type="text/javascript">
    function playSound(soundfile) {
    document.getElementById("dummy").innerHTML=
    "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
    }
    </script>

    </head>

    <body>
    <span id="dummy"></span>
    <div><%=error%></div>
    <div id="captcha">
    <img src = "vcaptcha.jsp" ID = "captcha">


    <img src="speaker.gif" alt="" name="image" width="50" height="50" id="" onmouseover="playSound('crowd.mp3');"/>

    <br /> <br />
    </div>
    <form name="frmLogin" onSubmit="return validate();" onReset="return refresh();" method="post">

    Captcha Code <input type="text" name="usrValue" /><br />
    <br />
    <input type="reset" name="Refresh" value="Refresh" />
    <input type="submit" name="Submit" value="Submit" />
    </form>
    </body>
    </html>
    and got my vcaptcha.jsp code from here... i need it to be done by friday... so its urgent plz if posb help me out...

  4. #4
    Join Date
    Jul 2012
    Posts
    7
    one more problem now i m facing... after ur code.. i am able to refresh when i click on to refresh button but when i take my mouse on speaker image then it gives me error and does not play any single sound.. it is working properly when there is no refresh button code is there... the updated code i have already posted...

  5. #5
    Join Date
    Mar 2012
    Posts
    202
    Quote Originally Posted by KushBhargava View Post
    HTML Code:
    <div id="captcha">
    <img src = "vcaptcha.jsp" ID = "captcha">
    You have used the ID "captcha" for multiple elements. In order for JavaScript to correctly locate elements using the getElementById function, the query ID must be unique.

    As for the audio, the only way to complete that with javascript is to create multiple audio files and get them to be played sequentially. The only problem with that is, an application could be designed to read the JS coding of the audio algorithm in order to circumvent the purpose of using captcha... I would look around on the internet for ways of combining audio files to be sent to the client through the use of server-side code such as PHP. I hope I didn't make this sound too difficult for you...

  6. #6
    Join Date
    Mar 2012
    Posts
    202
    actually it would be worthy to note that the captcha on that page is made using flash/php...
    Last edited by Gray1989; 07-11-2012 at 02:00 PM.

  7. #7
    Join Date
    Jul 2012
    Posts
    7
    yes you are right... but where i m working as a trainee. they want in java... as this is my first assignment i m little bit stressed too...

  8. #8
    Join Date
    Mar 2012
    Posts
    202
    Okay, that's alright. But the sound isn't necessary, is it? I mean combining sound files using JS isn't exactly reliable because there will have to be multiple sound files loaded and played using timeouts. If you could get the sound files and write down the lengths of each, I'll help you write the code to string it all together.

  9. #9
    Join Date
    Jul 2012
    Posts
    7
    let me tell you what i m trying to do...

    just like a random string D4eSro

    sound will be uppercase d number 4 lowercase e uppercase S lowercase r lowercase o

    i have all these sounds but dont know how to implement it and form sound captcha i need in java (server side)

  10. #10
    Join Date
    Jul 2012
    Posts
    7
    if u have any other better way for this... i have no problem in using...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles