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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:35:02+00:00 2026-06-07T13:35:02+00:00

Hi all this is how i set value is hidden variable through java script,

  • 0

Hi all this is how i set value is hidden variable through java script,

function logintosystem(){
                document.forms["frmLogon"].funtiontype.value="logon";
                document.forms["frmLogon"].submit();
            }

and this is what is my jsp page :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String path = "", userName = "", message = "", userType = "";
    path = request.getContextPath();
     if(request.getAttribute("message")!=null) message =(String)request.getAttribute("message");
%>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="description" content="ACCT"/>
        <meta name="keywords" content="acct,accesscardcomparision" />
        <meta name="author" content="slingmedia" />
        <link rel="stylesheet" type="text/css" href="acct.css" title="andreas09" media="screen,projection" />
        <title>ACCT</title>
        <script>
            function logintosystem(){
                document.forms["frmLogon"].funtiontype.value="logon";
                document.forms["frmLogon"].submit();
            }

        </script>
    </head>
    <body>

        <div id="container">
            <div id="sitename">
                <h1>ACCT</h1>
                <h2>Access Card data comparision with Leave portal</h2>
            </div>
            <div id="mainmenu">
                <ul>
                    <%
                        if (userName.length() > 0 || !userName.equals(null) || !userName.equals("")) {
                    %>
                    <li><a href="#" class="current" >Welcome <%=userName%></a></li>
                    <%}%>
                    <%
                        if (userName.length() > 0 && userType.length() > 0) {
                    %>
                    <li><a href="#">Tempcard</a></li>
                    <%}%>
                    <%
                        if (userType.equals("HR")) {
                    %>
                    <li><a href="#">Report</a></li>
                    <%}%>
                    <%
                        if (userName.length() > 0 && userType.length() > 0) {
                    %>
                    <li><a href="#">Logout</a></li>
                    <%}%>
                </ul>
            </div>
            <div id="wrap">
                <div id="content">

                    <h1>Please Enter your code</h1>
                     <form name="frmLogon" id="frmLogon" action="LogonServlet" method="post">
                    <table align="center" border="0" cellpadding="0" cellspacing="0"  width="100%">
                        <tr align="center" valign="middle">
                            <td width="100%" align="center" valign="middle">
                                <table width="100%" align="left" border="0" cellspacing="0" cellpadding="2" >
                                    <tr>
                                        <td width="5%" align="left">&nbsp;</td>
                                        <td width="35%" align="right">ACCT Code</td>
                                        <td width="20%"><input type="text" name="acctcode" id="acctcode" class="inputBoxes" /></td>
                                        <td width="15%" align="left"><input type="button" class="submitButton" value="Logon" onclick="logintosystem();"/></td>
                                        <td width="15%">&nbsp;</td>
                                        <td width="10%" align="center">&nbsp;</td>
                                    </tr>
                                    <br></br>
                                </table>
                            </td>
                        </tr>
                    </table>
                         <input type="hidden" name="funtiontype" id="funtiontype" value=""/>
                 </form>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFF0">
                        <tr>
                            <td id="message"  align="center">
                                <b><font  color="brown" size="3"><%=message%></font></b>
                            </td>
                        </tr>
                    </table>
                    </td>
                    </tr>
                    </table>
                </div>
                <div class="clearingdiv">&nbsp;</div>
            </div>
        </div>

        <div id="footer">
            <p>&copy; 2012 <a href="#">slingmedia</a> | ACCT&nbsp;&nbsp;&nbsp;<a href="http://slingmedia.com/"></a></p>
        </div>
    </body>
</html>

and my servlet is :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.slingmeadia.notifier.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author anthony.savarimut
 */
public class LogonServlet extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /*
             * TODO output your page here. You may use following sample code.
             */
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet LogonServlet</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet LogonServlet at " + request.getContextPath() + "</h1>");
            out.println("</body>");
            out.println("</html>");
        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
       // processRequest(request, response);
        String funtiontype = "",acctcode="",pageRedirect="";

        if(request.getAttribute("funtiontype")!=null) funtiontype =(String)request.getAttribute("funtiontype");
        if(request.getAttribute("acctcode")!=null) acctcode =(String)request.getAttribute("acctcode");

        if(funtiontype.equals("logon")){
            request.setAttribute("message","Loggedon code is "+acctcode);
            pageRedirect="notifier/notifier.jsp";
        }else{
            request.setAttribute("message","loggedout code is "+acctcode);
            pageRedirect="index.jsp";
        }
        response.sendRedirect(pageRedirect);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //processRequest(request, response);
        System.out.println("Called logon");
        doGet(request,response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}

the page is getting submited but the values that i set for hidden variable is not coming in servlet also i have a text box that value also is not coming to servlet when submitting the page.

Kindly help me to find out this.

  • 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-07T13:35:04+00:00Added an answer on June 7, 2026 at 1:35 pm

    You should do this:

    funtiontype =request.getParameter("funtiontype");
    acctcode = request.getParameter("acctcode");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script set up that echoes all relevant users in a database
Hey all. I'm trying to set a value on a hidden form element based
Hey all how can i set this up for a loop? data.row9_1 I cant
We all know to set canvas's context property like this: ctx.textBaseline = top; ctx.shadowColor
hi all i have jqgrid and set update inline . i wrote this code
There's a shortcut to this without having to specify SET all the time right?
this is really doing my nut..... all relevant PHP Output scripts set headers (in
Hi all this is my xml file with xsd defined as internal to it
hello all this seems to be my problem I have a table in mysql
How can I get all this to not only output on the screen, but

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.