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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:58:34+00:00 2026-05-27T06:58:34+00:00

Here is the problem, i have 3 JSP pages ( main.jsp , manageClasses.jsp and

  • 0

Here is the problem, i have 3 JSP pages (main.jsp, manageClasses.jsp and insertDates.jsp) and 2 Servlets (AttendanceServlet and ManageClassServlet). The main page loads the other ones inside itself.

Basically what i want to do is upon calling the AttendanceServlet i want to load insertDates.jsp into main.jsp. Replacing the previous content which was loaded by ManageClassServlet.

main.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="js/jquery-1.7.min.js"></script>
        <link rel="stylesheet" href="css/stylesheetprincipal.css">
        <script type="text/javascript">  
            $(document).ready(function() {
            $("#gt").click(function(){
                $("#internal").load('ManageClassServlet');
            });
        });
        </script>
        <title>Main</title>
    </head>
    <body>
        <div id="nav">
            <ul>
                <li><a href="javascript:void(0)" id="gt" title="manage">MANAGE     CLASSES</a></li>  
                <li><a href="logout.jsp" title="exit">EXIT</a></li>
            </ul>
        </div>    
        <div id="forms">
            <div id="internal">
            </div>
        </div>
    </body>
</html>

ManageClassServlet

@WebServlet(name = "ManageClassServlet", urlPatterns = {"/ManageClassServlet"})
public class ManageClassServlet extends HttpServlet {

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, java.io.IOException {
        HttpSession session = request.getSession();
        String[][] tableMatrix = getTableMatrix(professorClasses);
        session.setAttribute("tableMatrix", tableMatrix);
        response.sendRedirect("manageClasses.jsp");
    }
}

manageClasses.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Manage Classes</title>
    </head>
    <body>
        <form action="AttendanceServlet" method="post">
            <table id="classTable" border="2">
                <TR> <TH>&nbsp;</TH> <TH>Subject</TH>  <TH>Year/Semester</TH>  <TH>Frequencias</TH> </TR>
                <c:forEach items="${matrixTable}" var="row" varStatus="i">
                    <tr>
                        <TH>${row[0]}</TH>
                        <c:forEach begin="1" end="2" items="${row}" var="value">
                            <td>${value}</td>
                        </c:forEach>
                        <td> <button type="submit" name="Ver" value="${row[3]}">See    </button> </td>
                    </tr>
                </c:forEach>
            </table>
        </form>
    </body>
</html>

I was trying to use the out Object to send the jsp page but it didnt work.

AttendanceServlet

@WebServlet(name = "AttendanceServlet", urlPatterns = {"/AttendanceServlet"})
public class AttendanceServlet extends HttpServlet {

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, java.io.IOException {
        try {
            ClassDAO classDao = new ClassDAO();
            Integer idClass = Integer.parseInt(request.getParameter("See"));
            ClassBean class = classDao.searchClassBean(idClass);
            if (class.getDateClasses() == null) {
                String path = "/WEB-INF/jsp/main.jsp";
                PrintWriter out = response.getWriter();
                out.println("<script type=\"text/javascript\">");
                out.println("$(document).ready(function() {");
                out.println("$(\"#internal\").load('insertDates.jsp');");
                out.println("});");
                out.println("</script>");
                RequestDispatcher dispatcher = request.getRequestDispatcher(path);
                dispatcher.include(request, response);
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
}
  • 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-27T06:58:35+00:00Added an answer on May 27, 2026 at 6:58 am

    It took a while before I could wrap my head around the odd way of loading, redirecting and dispatching the (sub)views in this particular example. It’s hard to pinpoint the root cause of your problem. At least, it’s clear that you’re going pretty overboard with jQuery. To start, if the client has JS disabled, then your main page is already entirely useless.

    To achieve whatever you want, you first have to separate client side responsibilities from the server side responsibilities. Put jQuery out of your head for a while and get it to work with normal <form> and/or <a> elements and <jsp:include> first. If you keep all Java code in Servlet class and keep all HTML/CSS (and any future JS) in the JSP file, then the code will almost write itself.

    Finally, once you get it all 100% to work without any line of jQuery/JS code, then you can progressively enhance the client side experience by adding jQuery in an unobtrusive manner. I.e. the server side functionality (as you have in servlet and JSP) must not be changed (apart from eventually checking if it’s a normal or an ajax request so that a more suitable response can be given). The jQuery has just to add event handlers during document load and change the document behaviour in such way that it improves the user experience (again, without changing the server side code). jQuery isn’t a MVC framework at its own or something. And no, you should not let the servlet emit any jQuery code. This makes no sense.

    Again, sorry if I don’t have a ready-to-fit answer for this, but you hopefully understand now that I am simply unable to do so. Kudos for clean code style and a good startoff with Servlet/JSP though. I’d only lowercase those <TH><TR> elements.

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

Sidebar

Related Questions

Here is a problem I have encountered. I have jsp page which has a
Greetings, here is the problem. I have a page called entList.jsp , that works
Here's the problem: I have couple of pages which gets its content from a
I have a JSP page which loads another jsp page's content which is working
I have a problem in my Java webapp. Here is the code in index.jsp:
Here is the problem I have: I have a lot (tens of thousands) of
Here's my problem - I have some code like this: <mx:Canvas width=300 height=300> <mx:Button
Here's my problem: I have a virtual method defined in a .h file that
Here is the problem: we have lots of Javascripts and lots of CSS files,
Here's my problem: I have to call a web service with a secure header

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.