Question

I'm new to Bootstrap. But I'm pretty familiar with HTML. The thing is I cannot get parameter values from JSP. The parameters are from HTML page with Bootstrap 3. Here're the code. I don't understand. If I make simple html only page, then I could get the parameters.

<form class="form-horizontal" method="POST" action="makeResv.jsp">
    <div class="container"> 
        <div class="row">           
            <div class="control-group col-md-5">
                <label for="checkIn">date1</label>
                <div id="date-container">
                    <div class="input-group date">
                        <input type="text" id="checkIn" class="form-control"><span
                            class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
                    </div>
                </div>
            </div>
            <div class="control-group col-md-5">
                <label for="checkOut">date2</label>
                <div id="date-container">
                    <div class="input-group date">
                        <input type="text" id="checkOut" class="form-control"><span
                            class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <button type="submit" class="btn btn-success">search</button>
            </div>
        </div>
    </div>
</form>

In a JSP page, I'm just doing the following.

String checkIn = request.getParameter("checkIn");
String checkOut = request.getParameter("checkOut");
out.println(checkIn + " " + checkOut);

What's wrong with the above HTML code with Bootstrap?? Please give me some advise. Thanks!!

BTW, I'm using datepicker JavaScript library, but I don't think that affect the results. I cannot add the library code here but it works great anyway. https://github.com/eternicode/bootstrap-datepicker

Était-ce utile?

La solution

Bootstrap is same as HTML. The problem you are having is because you do not have any name attribute defined in your input element. You define id but to access submited variables via POST (request.getParameter() function) you need to have name attribute defined:

Replace <input> lines like this:

<input type="text" name="checkIn" id="checkIn" class="form-control">

And

<input type="text" name="checkOut" id="checkOut" class="form-control"><
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top