Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6329127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:35:43+00:00 2026-05-24T17:35:43+00:00

I have a serious problem. Firstly, I am trying to retrieve values from my

  • 0

I have a serious problem.

Firstly, I am trying to retrieve values from my database by individual scripts on my JSP pages. Here is part of the code:


<%String driver = "com.mysql.jdbc.Driver";

Class.forName(driver).newInstance();

Connection con=null;

ResultSet rst=null;`

Statement stmt=null;

try{

String url="jdbc:mysql://localhost:3306/MajorProjectDB?user=cdsadmin2&password=enjoyit";

con=DriverManager.getConnection(url);

stmt=con.createStatement();

}
catch(Exception e){
System.out.println(e.getMessage());
}

String name= request.getRemoteUser();

rst=stmt.executeQuery("select verifycode from Staff where name='"+name+"'");
%>

<%
int no=1;`
while(rst.next()){

%>

<%=no%>

<%=rst.getString("VERIFYCODE")%>

<%String code= request.getParameter("code"); %>

<% } %>

In this code I am storing a string from VERIFYCODE column in my Staff table.
I will be able to compare it with the user input within the form by using a getparameter.

HOWEVER, the comparison should be done with onClick function, but due to the fact that it is running as an individual script, it cannot be attached to the onClick function.

Now I am trying to insert an SQL statement in the following javascript in my JSP page:


<script type="text/javascript">

function verifyCode(){ 

// a SELECT sql statement which gets String from database

//comparison between String retrieved from database and user input

if{

  }

else{

}

}

</script>

May I know if anyone has any solution? Or is there a easier method of doing it?
Thanks in advance, any help is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:35:44+00:00Added an answer on May 24, 2026 at 5:35 pm

    Server converts jsp to HTML and sends to client and client gets only HTML javascript are executed on client side.

    For your case you can use DWR, to call java method from server from the javascript

    See Also

    • why-business-logic-should-be-moved-out-of-jsp
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have serious problem, I have deleted Java project from Eclipse and I don't
i have a serious problem. i would like to extract the content from tag
I have a serious problem with getting data from a sql query in php
We have a serious problem to tackle here. We are loading pdf documents as
I got a serious problem here: I have a scrolling background that is 1320
I have a serious problem. One of our servers crashed. Now I reinstalled the
I have this serious problem. I have an enumeration within 2 namespaces like this:
Ok guys, I have a serious problem with this. I have a static class
I have a very serious problem with Visual Studio 2008. Occasionally when I right-click
I am having a serious problem. What i have in my hand : Linux

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.