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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:30:46+00:00 2026-05-26T14:30:46+00:00

I have a JSP/HTML form with text box and radio buttons. I am saving

  • 0

I have a JSP/HTML form with text box and radio buttons. I am saving the data entered in the form in servlet context.

I am then jumping over to a new jsp/html page with the same form. Now I want to put the values entered previously back into the fields in this new form.

e.g. in text field user entered “ABC” which will be published in the new form using:

<INPUT TYPE="text" NAME="mytext" ID="mytext" value="<%=mytext %>">

How to do the same thing for the following: Drop down field, radio button field, check box field.

I have a group of radio button (e.g. in a search form the radio button values would be “begins with” or “contains” or “exact”. So one of the three will be saved in servlet context. How to republish the same in the new form ??

My radio button group is something like:

<TD valign="middle" align="left" width="100%" NOWRAP>
    <INPUT type="radio" name="searchCriteria" id="searchCriteria" value="NAME_BEGINS" onfocus="onFocusNameBegins();"/><b>Begins With</b>
    <INPUT type="radio" name="searchCriteria" id="searchCriteria" value="NAME CONTAINS" onfocus="onFocusNameContains();"/><b>Contains</b> 
    <INPUT type="radio" name="searchCriteria" id="searchCriteria" value="NAME_IS" onfocus="onFocusNameIs();"/><b>Exact Match</b> 
</TD>
  • 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-26T14:30:47+00:00Added an answer on May 26, 2026 at 2:30 pm

    To the point, you just need to set the selected attribute in the <option> to preselect the dropdown option value and the checked attribute in <input type="radio|checkbox"> to precheck the radio button or checkbox value.

    Assuming that your initial form look like this:

    <form action="next.jsp" method="post">
      <input type="text" name="text" />
      <select name="dropdown">
        <option value="one">One</option>
        <option value="two">Two</option>
        <option value="three">Three</option>
      </select>
      <input type="radio" name="choice" value="one" />
      <input type="radio" name="choice" value="two" />
      <input type="radio" name="choice" value="three" />
      <input type="submit" />
    </form>
    

    Then you can redisplay them by ${param.fieldname} in EL as follows:

    <form action="next.jsp" method="post">
      <input type="text" name="text" value="${fn:escapeXml(param.text)}" />
      <select name="dropdown">
        <option value="one" ${param.dropdown == 'one' ? 'selected' : ''}>One</option>
        <option value="two" ${param.dropdown == 'two' ? 'selected' : ''}>Two</option>
        <option value="three" ${param.dropdown == 'three' ? 'selected' : ''}>Three</option>
      </select>
      <input type="radio" name="choice" value="one" ${param.choice == 'one' ? 'checked' : ''}/>
      <input type="radio" name="choice" value="two" ${param.choice == 'two' ? 'checked' : ''}/>
      <input type="radio" name="choice" value="three" ${param.choice == 'three' ? 'checked' : ''}/>
      <input type="submit" />
    </form>
    

    Note that I added fn:escapeXml() there where you’re redisplaying user-controlled input inline of HTML. Otherwise you’re just creating a major XSS attack hole. Neither old fashioned Scriptlets nor the standard Java SE API have builtin XML escaping facilities to prevent XSS attacks.

    See also:

    • Our JSP wiki page
    • Our EL wiki page
    • Our JSTL wiki page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSP page with an HTML form: <form action=SERVLET> <input type=text name=name/><br>
I have the following JSP File and Servlet file <html> <head> <meta http-equiv=Content-Type content=text/html;
I have the following jsp file <%@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1%> <%@ page
Hello I have a jsp with an html form. I set the content type
I have a jsp/html form that collects an array of choices from user. For
I have 2 pages written in JSP the first page contains: <%@page contentType=text/html pageEncoding=UTF-8%>
i have made a small web application with form.html output.jsp ServletOne.java In the form.html,users
I have a jsp page(let's say page1.jsp) which have an html form with action=page2.jsp.
I have an html-form with several text fields. When I try to submit not
I have jsp file: <%@ page language=java contentType=text/html; charset=UTF-8 pageEncoding=UTF-8%> <%@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core%>

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.