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

  • Home
  • SEARCH
  • 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 8422297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:24:29+00:00 2026-06-10T03:24:29+00:00

I’m trying to set the default value for a drop down menu based on

  • 0

I’m trying to set the default value for a drop down menu based on information passed into the page. So far I have this:

<td>
    <select id="typeDropdown" name="typeDropdown">
        <option value="val1" selected="selected">Value 1</option>
        <option value="val2">Value 2</option>
    </select>
</td>

And that will always have the first value selected.

However, can I do something like this to set the default based on information given to the webpage?

<c:if test="${not empty data}">
    <c:set var="val" value="${data}" />
</c:if>
<td>
    <select id="typeDropdown" name="typeDropdown">
        <option value="val1" <c:if test="val eq 1">selected="selected</c:if> >Value 1</option>
        <option value="val2" <c:if test="val eq 2">selected="selected</c:if> >Value 2</option>
    </select>
</td>

where data is passed into the page as part of the request. I understand that the syntax is probably wrong, but I’m more interested in whether not the idea is sound.

EDIT 1:

So that didnt work. I received the following exception for my efforts:

org.apache.jasper.JasperException: An exception occurred processing JSP page /newInterface.jsp at line 127

124: <td>Field 1:</td>
125:    <td><select name="field1">
126:        <c:set var="tet" value="val1"/>
127:        <option value="val1" <c:if test="${old.val eq tet}">selected="selected"</c:if>>val1</option>
128:        <option value="val2">val2</option>
129:    </select>
130: </td>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)

old.val is, for all intents and purposes, the same as that “val” variable from my initial idea.

  • 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-10T03:24:30+00:00Added an answer on June 10, 2026 at 3:24 am

    1:
    … the idea is ok though, first get the data value output, then move on to the select, parsing errors can be cryptic so why not edit the question and add the error

    2:
    so make sure you can output that first as well, that might be why your ‘if’ blows up

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.