I am making an attendance app.
Among them, I would like to create a function using javascript that displays a list of employee information in a table when you click a link on the screen.

Currently, Java is used and the above functions are implemented by performing screen transitions.
(Click the link->SELECT employee information from DB in Action class->Store SELECT data in List->Display List value in table on jsp screen of transition destination.)

This flow,
(Click the link → Execute event by onClick etc. → Execute Java class related to DB connection → Store data in List → Display data in table (* Display this table at the bottom of the same screen as jsp with link Want to))

I want to make it like that.
(Is this way of thinking correct?)

〇 What i am looking for
I'm searching with keywords such as "javascript Java execution", and is it possible if I use a java applet now? I'm in the process of investigating.
However, I don't get the point, so I would like advice.

<% @ page language = "java" contentType = "text/html;charset = UTF-8"
    pageEncoding = "UTF-8"%><% @ taglib uri = "http://struts.apache.org/tags-html" prefix = "html"%><! DOCTYPE html><html: html><head>    <meta charset = "UTF-8">    <title>Insert title here</title>    <link rel = "stylesheet" href = "http: // localhost: 8081/Attendance_Apli/CSS/AttendanceCSS.css"></head><body id = "top_body">                <% String msg = (String) request.getAttribute ("msg");
            if (msg! = null) {
            %>        <p><% out.println (msg);%></p><br>        <%}%>           Attendance management           <br>        <html: form action = "/ attendance">                            <button type = "submit" name = "attendance" value = "I" id = "top_attend">Attendance</button>            <button type = "submit" name = "attendance" value = "O" id = "top_attend">Leave</button>                        </html: form>        <br>            <html: link action = "/ userlist">User list</html: link>//  I want to execute javascript from this link
          <br>               Attendance list (monthly)           <br>        <br>        <html: form action = "/ logout">            <html: submit property = "logout" value = "logout" />            </html: form>                    </body></html: html>
package list;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import database.DBManager;
import model.LoopListForm;
import model.UserActionForm;
/ **
 * @author cellua
 * Extract data from DB M_USER and
 * Display on the user list screen
 * /
public class UserListAction extends Action {
    public ActionForward execute
    (ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
throws Exception {
        Connection conn = DBManager.getConnection ();// DB connection

        // Receive the ID from session and go to select the authority
        HttpSession session = request.getSession (false);
        String userID = (String) session.getAttribute ("userID");
        String preSql = "SELECT AUTH FROM M_USER WHERE USER_ID ='" + userID + "'";
        Statement preSmt = conn.createStatement ();ResultSet preRs = preSmt.executeQuery (preSql);
        preRs.next ();
        String auth = preRs.getString ("AUTH");
        // Branch whether it can be displayed or not according to the authority of the logged-in user
        if (! auth.equals ("0")) {
            request.setAttribute ("msg", "You do not have permission to view the user list");
            return (mapping.findForward ("toTop"));
        // Select user data from DB
        String sql = "SELECT * FROM M_USER";
        Statement smt = conn.createStatement ();
        ResultSet rs = smt.executeQuery (sql);

        // Create list and loop for data storage
        List<UserActionForm>list = new ArrayList<UserActionForm>();
        LoopListForm loop = new LoopListForm ();
        while (rs.next ()) {
            // Create ActionForm instance
            UserActionForm uaf = new UserActionForm ();
            // Extract the information to be posted on the TOP screen
            uaf.setUserID (rs.getString ("USER_ID"));
            uaf.setName (rs.getString ("NAME"));
            uaf.setAuth (rs.getString ("AUTH"));
            uaf.setSex (rs.getString ("SEX"));
            uaf.setMail (rs.getString ("MAIL_ADDRESS"));
            uaf.setCreateDate (rs.getDate ("CREATE_DATE"));
            uaf.setDate (rs.getDate ("UPDATE_DATE"));
            list.add (uaf);
        loop.setLoop (list);
        request.setAttribute ("list", list);
        request.setAttribute ("loopData", loop);

        if (list.size ()>0) {
            // Screen transition to list screen
            DBManager.closeDataBase (smt, conn);
            return (mapping.findForward ("toUserList"));
        } else {
            // Transition to error screen
            DBManager.closeDataBase (smt, conn);
            return (mapping.findForward ("error"));
  • Answer # 1

    On the Java side, prepare a URL that "executes a specific action when accessed" and call it from JavaScript.

    Is it possible using a java applet?

    Java applets are a technology that has finished its role, and "accessing the DB from an applet" isClient using a browserIt means to access the DB directly from. For security reasons, this is not a structure that should normally be taken.