missing hidden field

Posted on 2006-04-10
Last Modified: 2010-03-31
Hello expert ,
I have hidden field in a jsp
<input type="hidden" name="actionRequired"/>

I set the value in a javascript as below

                   alert("passed validation criteria");
                  if(document.forms["limsRecordAdvancedSearchForm"].elements["useAltSearch"].checked == true)                                 
                        document.forms["limsRecordAdvancedSearchForm"].elements["actionRequired"].value = "ALTERNATESEARCH";
                  /*else if(trimString(document.forms["limsRecordAdvancedSearchForm"].elements["recordNo"].value) != "")
                        document.forms["limsRecordAdvancedSearchForm"].elements["actionRequired"].value = "SINGLERECORD";*/
                        document.forms["limsRecordAdvancedSearchForm"].elements["actionRequired"].value ="ADVANCEDSEARCH";
                        alert("setting actionRequired as" +actionRequired");

The filed needs to set itself to ="ADVANCEDSEARCH" which it does , I check it with alert statment ,
but in the action class when i try to read the parameter

actionRequired = request.getParameter("actionRequired");
is get a empty string .
Why would something like this happen , where could i be lossing the data for the hidden field .

plz advice
Question by:eldoz12
    LVL 14

    Expert Comment

    by:Tommy Braas
    Post to the JSP TA, this TA is for Java questions.
    LVL 5

    Expert Comment

    Your form needs to be submitted in Order to propogate the hideen fields to the next request.

    Just ensure that your form is getting submitted.

    and the code <input type="hidden" name="actionRequired"/>
    should be inside



    Author Comment

    yea it is between

    LVL 5

    Expert Comment

    Ensure that the form is submitted to propogate the value of the hidden field.

    form.submit is called.
    LVL 8

    Expert Comment

    Use getParameterNames() on the rquest object in your action class to get a list of all the args that are being passed to the servlet.

    This should help you debug, remember that java is case sensitive - could that be the problem?

    Note also that if the value you are getting is an empty string as opposed to null, then you are probably reading the value correctly at your action class end, which means that the javascipt itself isnt working. If you were trying to read a value that doesnt exist, im pretty sure you would get a null value

    LVL 5

    Accepted Solution


    <html:hidden property="actionRequired"/>

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    This video teaches viewers about errors in exception handling.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now