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 8156747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:03:19+00:00 2026-06-06T17:03:19+00:00

I have a jsp form validate.jsp which contains 2 text fields where user enters

  • 0

I have a jsp form validate.jsp which contains 2 text fields where user enters his/her roll number/name. I have also written some validation code using javascript to verify the input.

Now after collecting the input I forward these two parameters to another page result.jsp using jQuery ajax as shown below:

$("#student_result").load("result.jsp?"+ $.param( { rollNo: rollNo, name: name }));

Now my result.jsp page has to display result of the person whose roll no or name has been entered by the user. So, this result.jsp page contains all database logic(java code). But conventionally we should write all the business logic in a servlet. So I want to do this.

But, as you can see, I am loading the contents of result.jsp dynamically using ajax inside the validate.jsp page. If I use a servlet I need to use requestDispatcher which will forward to and hence load the entire result.jsp page!

I don’t want to do that! I still want to load result.jsp page contents dynamically in the validate.jsp page. How to do that?

Or will there be any complications if I keep the entire database logic in result.jsp file?

  • 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-06-06T17:03:21+00:00Added an answer on June 6, 2026 at 5:03 pm

    I think there are better approaches to solve your problem. If you don’t want to use a framework I think you should use servlets at least.

    If you still want to do it using only jsps your result.jsp should only return the fragment you want to load in you page, and not a whole html page.

    Another way to do it is with the next AJAX request:

    $("#student_result").load("result.jsp .roll", {rollNo: rollNo, name: name });
    

    The above will only load the element with the class roll.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one jsp form which contains the username textfield. On the click
I have the following code: index.jsp: <form name=f action=db/ajoutConducteur.jsp method=post> <input type=text pattern=\d{8} required
I have a jsp form which takes in user details. On submit button it
I have a JSP page with an HTML form: <form action=SERVLET> <input type=text name=name/><br>
I have a jsp which contains a html form. Inside it there is an
I have a jsp file: validate.jsp- var rollNo=document.forms[result_form][studentRollno].value; var name=document.forms[result_form][studentName].value; $(#student_result).load(result.jsp?rollNo=+rollNo+&name=+name); As you can
I have the following form in a Struts2 JSP that contains some radio buttons.
I currently have a JSP page with a Form for the user to enter
Hello i have a JSP page that contain a form, i want to validate
I have a JSP/HTML form with text box and radio buttons. I am saving

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.