How do you do Switch statement in JSP

using the HTML tags!

using the HTML tags!HTML has no switch capabilities.
If you mean using JSTL, then you can use the <c:choose>, <c:when> and <c:otherwise> tags to behave like an if else structure:
<c:choose>
  <c:when test="${var == 1}">
    //something
  </c:when>
  <c:when test="${var == 2}">
    //something
  </c:when>
  <c:otherwise>
    //something
  </c:otherwise>
</c:choose>

Similar Messages

  • How do you save "game state" so the user can continue next time?

    I'm not sure what the correct game terminology is for this, but how do you save "game state" so the user can continue next time?
    This seems like a pretty important feature for building some games, we don't want users to have to start over everytime.
    Any ideas if this is possible?

    Check out my blog post on the PersistenceManager:
    http://www.unitedmindset.com/jonbcampos/2010/11/01/flex-4-5-persistencemanager/
    This will help you understand how to store the data. When the app starts up again get the state information from the persistencemanager and reset you game to the state you need. It requires a bit of code for the startup, but it is relatively simple.

  • How would you change the state to the base state?

    How would you change the state to the base state? Its not
    letting me do something like:
    currentState='<Base State>';

    Sorry about the vagueness of that last reply :)
    What I have done now in my code is this:
    viewstack1.addChildAt(loginCanvas,0);
    toggle.selectedIndex = 0;
    However nothing happens at this line of code:
    toggle.selectedIndex = 0;
    but this works:
    toggle.selectedIndex = 1; or ...
    toggle.selectedIndex = 2;
    toggle.selectedIndex = 3;
    toggle.selectedIndex = 4;
    toggle.selectedIndex = 5;
    toggle.selectedIndex = 6;
    The strange thing is that if I have a button on the screen:
    <mx:Button x="10" y="3" label="Button"
    click="toggle.selectedIndex =0"/>
    and the user clicks it the toggle.selectedIndex = 0; works.
    I'm stumped, any ideas?

  • How to use switch statement in JSP?

    Hi,
    I am using switch satement in jsp.
    the code as follows:
    switch(flag)
         case 1: query="select * from cust";
                        break;
         case 2: query="select * from cust where minp="+mini+"and maxp="+maxi;
                        break;
        default: query="";
    out.println(query);but, i am getting some number format exception. I don't know where i am going wrong.
    Please help
    Regards,
    Ashvini

    I got the solution
    Thanks anyways
    Regards,
    AShvini

  • How Do You Set the State Of a Custom Compent's Child Custom Compent?

    I'm starting to build very complex interface 'widgets' built by taking simple custom compents and creating more complex custom compents from these compents and then again grouping those to create custom components. However, I'm starting to lose access in Catalyst to set these sub custom compents. It maybe just a noob issue.
    Am I looking at this wrong?
    Should I not be nesting compents?
    Other wise how do I access these?
    I haven't jumped into the code part of FLEX yet but I figured it would be very OOP like, so... (psuedo code)
    myParentCustomComponent.my1stChild.state = myChildsStateOn;
    //( myChildsStateOn, myChildsStateOff, myChildsStateNotVisited )
    myParentCustomComponent.my2ndChild.state = myChildsStateOn;
    //( myChildsStateOn, myChildsStateOff, myChildsStateNotVisited )
    I hope I can set this in Catalyst so that I don't have to do a shallow and very wide state setup like ... (psuedo code)
    myCustomCompent.state = my1stChildIsOn;
    myCustomCompent.state = my1stChildIsOff;
    myCustomCompent.state = my1stChildIsNotVisited;
    myCustomCompent.state = my2ndChildIsOn;
    myCustomCompent.state = my2ndChildIsOff;
    myCustomCompent.state = my2ndChildIsNotVisted;
    PLEASE ADVISE, thank you.
    Best Regards,
    -Truce

    Hi Truce,
         Thank you for your feedback. You have run into a current limitation with the "play transition to state" interaction and the "Set Component State" action in the timeline. Currently the UI that allows you to pick a state only "sees" components that are direct children of your current context. The state picker doesn't allow picking states of components that are more deeply nested.
    We are aware of this issue and how it impacts user's ability to author more complex projects, so we are looking at ways to allow users to pick states deeper within the hierachy when creating interactions.
    One work around that works in *some* cases is to set the state of sub components in a parent component using the PI rather than using interactions.
    If you have a structure like this
    Application
        WidgetA (with state1 and state2)
              WidgetB (with state1 and state2)
              WidgetC (with state1 and state2)
    You can record what state WidgetB and WidgetC are in for each state of WidgetA. To do this double-click WidgetA, select WidgetB and change the current state in the properties editor for WidgetB. That state will be remember for each state of Widget A. Then when you have an interaction at the application level that changes the state of WidgetA, then WidgetB will change state as well. This works well if WidgetB is in the same state for each state of WidgetA. If you want to change WidgetB and WidgetC states directly from the Application level, there isn't currently a way to do this.
    - Ty

  • How do you reinitialize a state everytime?

    hey guys... so got a quick question... how do i reinitialize a certain group everytime i change states?
    for example...
    in my parentApplication i have
        <s:states>
            <s:State name="loginPage"/>
            <s:State name="loginSuccess"/>
            <s:State name="apx32" />
            <s:State name="vista" />
        </s:states>
        <vista:vistaTroubleShoot name="vista" includeIn="vista" />
        <apx32:apx32TroubleShoot name="apx32" includeIn="apx32" />
        <panelSelection:loginSuccess name="panelSelect" includeIn="loginSuccess" />
    the vista, apx32 and panelSelection are component made of group.. so basically when if im in the component vista, and i change states to apx32
    and then from apx32 i change it back to vista i need everything in vista to have been reset....
    i hope im making sence...
    the problem im having is, when i switch back to vista state the list is selected on the one i selected previously.. lol hope that line makes sence...
    any help is greatly appretiated!!

    Yes!
    Disclaimer:
    The two VIs must be running in the same process context
    Translation:They both must be started from the same project or both opened without a project.
    If the two VI are opened from different projects LV will create a sepearte execution environment for both and they will not be able to to interact with the saem queue.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How do you reference image files in jsp which becomes a portlet ?

    My portlet is a servlet managing jsp pages. In each of the jsp s, there are image files (*.gif) being referenced. I have placed the image files in .../public_html/WEB-INF/images/ in explorer. In my jsp, I am referencing the image file as
    src="WEB-INF/images/help.gif"
    On deploying my portlet, the image is not being picked up by the portal. Also, on moving the image and modifying the reference to it, I am still getting the same problem.
    Can anyone advise, for my portlet to display the image correctly,
    1) where should I place the image files ?
    2) how should the jsp code reference it ?
    Cheers,
    Tara

    Hi,
    The behaviour you are reporting is an expected behaviour. If you want to include images in your JSP, you need to specify the complete absolute URL to the image on the midtier as only then can the portal invoke that image.
    Actually, when you specified the relative URL
    WEB-INF/images/help.gif, Oracle9iASPortal actually looks for the image help.gif in the directory structure WEB-INF/lib at its end. As no such file exists, the images are not rendered onto Oracle9iASPortal page.
    So you got to use the following workaround,
    Assuming your provider name is "temp" (deployed using temp.ear) & the image name is "help.gif" which is stored in the htdocs folder inside temp. This image is invoked by help.jsp
    You can get the absolute path of this image as follows:
    Request URL is : http://<host>:<port>/temp/providers/temp
    Request URI is : /temp/providers/temp
    So, Base URL = http://<host>:<port>
    Servlet Path is : /temp/htdocs/help.jsp
    Truncating the Servlet Path to /temp/htdocs & appending this to Base URL should give you
    http://<host>:<port>/temp/htdocs
    which is the directory that contains your image. add image name to this URL to get the absolute p[i]Long postings are being truncated to ~1 kB at this time.

  • How do you create down states in FW CS4

    on previous versions you could just double click the button
    and change the state by the tabs up top....i dont see that anymore
    can someone pleas help...thanks

    Open States Panel
    Right click first state and choose Duplicate (add as many
    states needed), then change the properties of the copied objects
    from state to state.
    h

  • How do you programmatically switch between a stack plot and an overlay plot with a waveform control?

    One method i realize is to have two waveform controls, one visible and one not visible. The real issue here is, how to dynamically control the number of plots in a stacked plot. My case,
    i will have between 2 and 8 channels. I have found that in the properties if i set the number of plots - Legend--Plots shown . I can control the number of stack plots, however, i must toggle from overlay to stack plots in design mode for the correct number of stack plots to be shown. Does anyone know a way around this problem or know of the property that has alluded me?

    Hi,
    You cant select between Stack plot and Overlay programmatically. Well not in LaBVIEW 5.1.1.
    You could have two Charts, one set up for Overlay and the other setup for Stacked. Then hide the one you are not immediately using.
    Ray.
    Regards
    Ray Farmer

  • How do you handle long strings between JSP forms and Oracle?

    I am using Apache 1.3.12 with JServ 1.1 and Oracle 8.0.4 on NT4 development Server.
    I am developing an application where one component allows authors to contribute articles or comments via a JSP page. I am noticing a problem when the info in the form gets too long (> 2000 characters). 99% of the inserts fall well within this limitation. The remaining 1% is sufficiently significant that I can't use a VARCHAR. It seems that SQL*NET chokes on large strings.
    My immediate workaround for these messages is to break them up into segments. Instead of storing the text or a message directly in a message table, I've added another table, msg_text, with columns msg_id, seg_num, and seg_text. On insert the message is split into segments limited to the smaller of the query limit and database varchar limit, minus the overhead of the sql query. This makes for an ugly insert operation, though and I would very interested to see if anyone out there has a better way to accomplish this task directly with CLOBs.

    The apparent problem with LONGs is that, of course, you can only have one per table.
    I had exactly this problem and ended up with several tables for one Business Entity, which is not really satisfactory.
    For the next phase of the Project, I will investigate:
    Putting these tables into a View.
    Putting Instead Of triggers on the View to "synchronise" changes to all underlying tables.
    Basing my BC4J Entity Object on the View...
    ... and I hope that Bob will be my uncle.
    I'd be interested to hear from anyone who has already tried this, or you if you give it a go.
    Rich

  • How to add an if statement in jsp?

    Hi all,
    I have a displayTag table and wonder how to have a condition on the following code:
      <display:column title="Accept?">
                <html:multibox property="select" value = "<%=bean.toString() %>" />
               </display:column>Basically, I would like to have this code (checkBox) appear only if a bean property is true (otherwise don't show it)
    if (bean.userApprove)
    // don't show checkBox
    else
    //show the checkBoxthanks for any pointers

    <%
    if (bean.userApprove)
    %>
    // don't show checkBox
    <%
    else
    %>
    <input type=checkbox name=chk value=chk />
    //show the checkBox
    <%
    %>

  • How do you properly switch off music?

    I posted the following in the connecting forum but should have probably posted this here:
    Usually when I'm finished listening to my music I use the remote and press the middle button once and it stops the music play and the iPod goes to sleep. Occassionally I'll notice that the player is on when I'm sitting at my desk. Is this the proper way to stop the music player and letting the iPod to sleep. I really don't want to do a full shut down and restart as I listen to it in shuffle mode and like to pick up where I left off. I just want to make sure I'm turning it off properly.

    This is a hardware issue. It is likely that you will need to have it replaced.
    See these threads for more details:
    http://discussions.apple.com/message.jspa?messageID=10396611#10396611
    http://discussions.apple.com/message.jspa?messageID=10371519#10371519
    -Matt

  • How do you easily switch Bluetooth headset between iPhone and MacBook Air

    I Have a Bluetooth headset that can pair between my mac and my iPhone individually.  However I only want my phone when I'm out and when I get home, id like to click the Mac and pair the headset without having to set the Bluetooth into the "searching mode".
    Wondering if anyone else is having this problem.  

    For this to work the Drafts Mailbox should be set to live on the server, not locally.
    Check in Settings > Mail, Contacts, Calendars > [Your iCloud account] > Mail > Advanced > Drafts Mailbox

  • How to convert switch statement into iif than else statement in SSRS

    Hi All;
    How do i convert switch statement into iif statement in ssrs
    =
    Switch(
    Fields!createdonValue.Value = Now(), "Today",
    Fields!createdonValue.Value = DateAdd("d",-1,Today()),"Yesterday",
    Fields!createdonValue.Value >= FORMATDATETIME(DateAdd(DateInterval.Day, -6,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate) and
    Fields!createdonValue.Value <= FORMATDATETIME(DateAdd(DateInterval.Day, -0,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate),"Last Week",
    Fields!createdonValue.Value >= FORMATDATETIME(DateAdd(DateInterval.Day, -13,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate) and
    Fields!createdonValue.Value <= FORMATDATETIME(DateAdd(DateInterval.Day, -0,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate),"Last Fortnight",
    Fields!createdonValue.Value >= DateValue(DateAdd("M",-1,DateAdd("D",-(Day(Now)-1),Now))) and
    Fields!createdonValue.Value <= DateValue(DateAdd("D",-1,DateAdd("D",-(Day(Now)-1),Now))),"Last Month",
    Fields!createdonValue.Value >= DateSerial(Year(Now()), 1, 1) and
    Fields!createdonValue.Value <= DateSerial(Year(Now()), 12, 31),"Year to Date"
    Any help much appreciated
    Thanks
    Pradnya07

    Not sure why you want to se IIF as Switch is more compact
    Anyways it will look like this
    =IIf(
    Fields!createdonValue.Value = Now(), "Today",IIf(
    Fields!createdonValue.Value = DateAdd("d",-1,Today()),"Yesterday",Iif(
    Fields!createdonValue.Value >= FORMATDATETIME(DateAdd(DateInterval.Day, -6,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate) and
    Fields!createdonValue.Value <= FORMATDATETIME(DateAdd(DateInterval.Day, -0,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate),"Last Week",IIf(
    Fields!createdonValue.Value >= FORMATDATETIME(DateAdd(DateInterval.Day, -13,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate) and
    Fields!createdonValue.Value <= FORMATDATETIME(DateAdd(DateInterval.Day, -0,DateAdd(DateInterval.Day, 1-Weekday(today),Today)),DATEFORMAT.ShortDate),"Last Fortnight",IIf(
    Fields!createdonValue.Value >= DateValue(DateAdd("M",-1,DateAdd("D",-(Day(Now)-1),Now))) and
    Fields!createdonValue.Value <= DateValue(DateAdd("D",-1,DateAdd("D",-(Day(Now)-1),Now))),"Last Month",IIf(
    Fields!createdonValue.Value >= DateSerial(Year(Now()), 1, 1) and
    Fields!createdonValue.Value <= DateSerial(Year(Now()), 12, 31),"Year to Date")))))
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to use * / - + in a switch statement?

    So I wrote a calculator program (im just learning Java).
    As a beginner I used the (press 1 for +, press 2 for - etc) now I want to go back and actually parse the real symbils * / - + and use those...
    I am using JOptionPane library for getting numbers and stuff.. (inputting them as String then converting to doubles)...
    How do I go about the operator symbols though? I can grab as as string no problem.. but then what?
    Ive been trying to figure out how to make a switch statement.. but case *: doesnt work.. it doesnt like the *. Cant convert that to an into or a double (at least I dont think you can?) or is switch statement a bad way to go in this case?
    Any help would be appreciated. :)

    endasil wrote:
    I should mention that it's extremely easy to form a switch statement that wouldn't have a performance benefit, by making the options very sparse. Like this:
    int i = 1000;
    switch ( i ) {
    case 1:
    break;
    case 1000:
    break;
    }Since this is not going to be implemented as a branch table (given the values are so sparse) it probably provides no benefit.
    enums, on the other hand, will be extremely fast in a switch since their integer values (ordinals) are packed as tightly as possible, starting at 0, by the compiler.
    I wonder how Strings will fare in this regard. I suppose if the compiler mods the hashCode, it can pack the possible values fairly tightly. Also, I presume that the cases will have to be compile-time constants.
    But the weirdest part to me is that it'll be actually computing the hash code of Strings at compile time. At first I thought this was reasonable when I discovered that String.hashCode's result was specified by the JLS [http://java.sun.com/docs/books/jls/first_edition/html/javalang.doc11.html#14460]. However, following JLS 1, those sections have been removed. So where is the specification for Java libraries now? Is it simply the Javadoc (String#hashCode()'s Javadoc does specify the actual result of computation)?
    Hmmm... The cases have to be compile-time constants, so that means strings will be in the constant pool, so I guess the compiler will build the lookups based on something that won't change for a given compiled .class file, regardless of which JVM loads it.

Maybe you are looking for

  • DST iCal bug (at least for Sony Ericsson mobiles)

    The recent Daylight Savings changes caused a baffling bug to show itself. I keep my phone's calendar (Sony Ericsson K610i) synchronised with my iCal calendar. This includes my timetable for the academic term, with about 13 weekly recurring events. As

  • Ipod touch will not let me sign in itunes and wont let me update need help

    need help

  • Print A4 PDF streched on A3 paper

    I'm having a strange issue, the main goal is to print a pdf file with A4 size pages streched on A3 paper from my application via DDE, but the result is always a A3 paper with A4 pages :-/. In Reader I set page scaling to "Fit to printable Area" and t

  • Error Message in Code Behind Visual Web Part

    I want to show validation message in code behing when i click submit button,below is my code <asp:TextBox ID="txtBoxName" runat="server" Width="50%"></asp:TextBox> <asp:RequiredFieldValidator ID="rfvCompanyName" ControlToValidate="txtBoxName" Validat

  • Contact for accounts and account Sites-Diffrence

    HI, I want your help in understanding the difference between a. when a contact is associated at the account level to b. when a contact is associated at an account site level in TCA. What is the difference between the two? Will the site level contact