Please help this clueless beginner with out.print syntax....

Please help a clueless beginner out!!!! :-)
I'm trying to build a dynamic table that functions as a calendar...(see http://www.oreilly.com/catalog/javacook/chapter/ch18.html for the basic idea and code structure).
Here's the problem...I want to make each date inside of the table a hyperlink to a new page. I figured out how to create the hyperlinks, but I CAN'T figure out how to create hyperlinks that pass variables to a new page.
Here's the code that works:
// Fill in numbers for the day of month.
for (int i = 1; i <= daysInMonth; i++)
out.print("<td>");
out.print("<a href=newpage.jsp>");
out.print(i);
out.print("</a>");
out.print("</td>");
Here's the code that DOESN'T work....but can serve as pseudo-code for what I want to do:
// Fill in numbers for the day of month.
for (int i = 1; i <= daysInMonth; i++)
out.print("<td>");
out.print("<a href=newpage.jsp?year=<%= yy %>&month=<%= months[mm] %>&date=<%= i %>>");
out.print(i);
out.print("</a>");
out.print("</td>");
<%= yy %>, <%= months[mm] %> are defined elsewhere in the code, and I want to use the current value of "i" from the loop.
So, if everything works like I want, the table will get created, and if yy=2002 and mm=January, then the hyperlinks will look like:
for day 1:
"/newpage.jsp?year=2002&month=January&date=1"
for day 2:
"/newpage.jsp?year=2002&month=January&date=2"
...for day 31:
"/newpage.jsp?year=2002&month=January&date=31"
Can someone please point me in the right direction? Is it even possible to do what I want? (I assume it is...but maybe I can't use out.print???)
Thanks!

Hi. The expression "<%=some_Java_expression %>" is the JSP tag, that returns string value to HTML code. You should use it in HTML block like:
<%String myname="Ivan"; %>
<body>
<p>My name is: <%=myname %></p>
But You tried to use it inside the string expression and it generated some code like this:
<a href="newpage.jsp?year=<%=yy%">...
, didn't it?
It invokes method out.print(" ... "), that prints this string value (but in the HTML block). So You tried to print something inside the print method. You should rewrite Your code like this:
for (int i = 1; i <= daysInMonth; i++)
out.print("<td>");
out.print("<a href=newpage.jsp?year="+yy+"&month="+months[mm]+"&date="+i+">");
out.print(i);
out.print("</a>");
out.print("</td>");
I used the + operator to join Your code for link tag with the values (yy, months[mm], i.
I hope it helps You,
bye.</a>

Similar Messages

  • Someone please help a complete beginner with Enterprise Manager!

    Question moved from
    Someone please help a complete beginner with Enterprise Manager!
    Please be gentle with me, I'm absolutely new to all this. We don't have a proper DBA and I've been tasked with the role. There is no-one else in the company with oracle experience and we don't have any support. Until now I've just used enterprise manager to manage the database, but now I have a problem..
    We are using Windows Server 2003 and Oracle 10g. I (stupidly) installed some network monitoring software on our server (PRTG network monitor). I almost immediately uninstalled it and all components/registry settings, but it seems to have thrown something out regards the OEM web interface.
    We used to access the OEM GUI through http://<hostname>:5500/em, but after installing/uninstalling the network monitor software the OEM webpage would only stay up for a few minutes, before saying 'Internet Explorer cannot display the webpage'. Restarting the DBconsole in services fixed the problem, but again, only for a few minutes.
    Spent all day yesterday looking at logfiles (they didn't make much sense to me), but seemed to be saying access was denied to the server ('actively denied it'). Lots of googling led me to believe I needed to reconfigure OEM by dropping and recreating it using:
    emctl stop dbconsole
    emca -deconfig dbcontrol db
    emca -repos recreate
    during this process I was asked for various passwords and a port number? I didn't even know what to use as the port number but guessed it was 5500 ?!? (probably wrong). As it didn't work I used the default port number that I found somewhere on the web.
    However now I am even deeper in the **** as this didn't work either, (some error about listnener?) and I have now lost the DBConsole in windows services. Obviously the OEM web console doesn't work at all now
    I would be eternally grateful for some patient, beginners help here..I can post whatever log files are necessary - I just need to know what I'm supposed to be doing and where to start..
    We used to log on to the OEM as 'SYSTEM', but nowhere in the process does it seem to ask me for the password for that (its asked me for SYS and SYSMAN)
    It could be that I'm going about this completely wrong, but with only a days experience in all this its pretty hard to know what I'm doing really!
    As you can tell I'm in way over my head..I just need OEM web interface to work!
    Thanks in advance

    ok, thanks to helpful comments from other people in my initial thread (posted in general database forum), after rebuilding the console/repository I now have EM up and running. But there are more problems..
    Firstly I have an error at the very top of the screen:
    java.lang.Exception: Number of responses does not match queries
    Also, the 'Host CPU' and 'Active Sessions' are blank and say 'No Data Is Currently Available' beneath them
    my emagent.trc file contains this error, repeating with different thread IDs every 30 seconds...
    (error = 10061)
    2012-04-30 17:19:28 Thread-4376 ERROR pingManager: nmepm_pingReposURL: Cannot connect to http://hostname:5500/em/upload/: retStatus=-1
    2012-04-30 17:19:59 Thread-1448 WARN http: snmehl_connect: connect failed to (hostname:5500): No connection could be made because the target machine actively refused it.
    Help!

  • PLEASE HELP THIS SIMPLE MAN WITH A VERY SIMPLE QUESTION

    Hi and thank you for looking.
    I am not musically inclined, challenged in fact. However I am making an iDVD and putting music to my slideshows but the program only lets me put 1 song for an entire group of pictures resulting in hearing the same song OVER AND OVER.
    My question for all you experienced garage band people is, is it possible to put a few songs together in garage band and then save them all as 1 song and then export it out to itunes so that I can put it into iDVD?
    Remember I have very little knowledge in using garage band so you may have to dumb it down for me but I am quite experienced with iDVD and iTunes now.
    Thanks for ANY and all help
    Mac

    Well, I won't explain all of GB in one post (look at the introductory videos on Apple's GB website), but yes, it's very easy to do that:
    • Create a new project and put your slide show video in the video track.
    • drag all the songs you want to use into the timeline, they will all get their own music track (note that you can't use DRM protected songs from the iTunes store that way).
    • Cut them wherever you want (using the Apple-T command) and move them around as you like.
    • If you want the songs to fade into each other, you'll have to use volume curves (look for "curves" in the Help menu).
    • When you like the result, share your project to iTunes (either the whole video, or just the audio which you later add in iPhoto or iDVD or iMovie).

  • I am having a problem with pop pups and small windows with ads constantly opening up on my safari?? Thought that macs didn't get virus? this looks like one- any experts around? please help me fix it with your instructions? really don't know what to do...

    Hi everyone,
    I am having a problem with my Mac OS X 10.7.5 mac book air , there are constant pop pups and small windows with ads blinking constantly opening up on my safari in front of everything?? it is constantly interupting me and makes me mistakingly click on it then another new windows open behind the one im using..
    I am not too sure if thats a virus or trojan.. I always thought that macs didn't get virus? this looks like one to me… any experts around? please help me fix it with your instructions? really don't know what to do... thanks

    Those are not viruses. You have probably installed some malware:
    The Safe Mac » Adware Removal Guide
    Helpful Links Regarding Malware Protection
    An excellent link to read is Tom Reed's Mac Malware Guide.
    Also, visit The XLab FAQs and read Detecting and avoiding malware and spyware.
    See these Apple articles:
              Mac OS X Snow Leopard and malware detection
              OS X Lion- Protect your Mac from malware
              OS X Mountain Lion- Protect your Mac from malware
              About file quarantine in OS X
    If you require anti-virus protection Thomas Reed recommends using Dr.Web Light from the App Store. It's free, and since it's from the App Store, it won't destabilize the system. If you prefer one of the better known commercial products, then Thomas recommends using Sophos.(Thank you to Thomas Reed for these recommendations.) If you already use Sophos, then be aware of this if you are using Mavericks: OS X Mavericks- Sophos Anti-Virus on-access scanner versions 8.0 - 9.1 may cause unexpected restarts
    From user Joe Bailey comes this equally useful advice:
    The facts are:
    1. There is no anti-malware software that can detect 100% of the malware out there.
    2. There is no anti-malware that can detect anything targeting the Mac because there
         is no Mac malware in the wild, and therefore, no "signatures" to detect.
    3. The very best way to prevent the most attacks is for you as the user to be aware that
         the most successful malware attacks rely on very sophisticated social engineering
         techniques preying on human avarice, ****, and fear.
    4. Internet popups saying the FBI, NSA, Microsoft, your ISP has detected malware on
        your computer is intended to entice you to install their malware thinking it is a
        protection against malware.
    5. Some of the anti-malware products on the market are worse than the malware
        from which they purport to protect you.
    6. Be cautious where you go on the internet.
    7. Only download anything from sites you know are safe.
    8. Avoid links you receive in email, always be suspicious even if you get something
        you think is from a friend, but you were not expecting.
    9. If there is any question in your mind, then assume it is malware.

  • Please help this: JNLP association extensions confict with arguments

    Hello, Please help this:
    I use <argument> tag to transfer some parameters to JWS application.
    I also use <associatio> tag to associate a specila file(such as .zzz) to JNLP. But when I doulbe click .zzz file, my application only get "-open" and file path as argument, those parameters in <argument> tag in my jnlp are lost!
    What should I do

    ..Is this a bug for JWS? No.
    ..association extensions tag conflicts with <argument>?Quoting the 'JNLP Specification', section 3
    'JNLP file', part 5 'Descriptor Information', under
    association element/mime-type attribute
    "An application making such a request
    should be prepared to have its main
    method invoked with the arguments
    -open filename and -print filename
    instead of any arguments listed with
    the application-desc element."

  • HT1689 i have my daughters iphone 3, i want to use it as an i-pod, but it keeps receiving messages from some her friends is there a way to stop this from happening, please help, my phone is maxed out and would really like the storage for music, thanks

    i have my daughters iphone 3, i want to use it as an i-pod, but it keeps receiving messages from some her friends is there a way to stop this from happening, please help, my phone is maxed out and would really like the storage for music, thanks

    It sounds like it still has her information on it, so it might be efficient to navigate to Settings, then General, then Reset, then Erase All Content and Settings. You can then set up the phone again, using your information. This way the phone will be yours, officially, and her data and information will be removed.

  • Please HELP! NEEd to figure out if my computer can install cs6

    I'm trying to figure out if it is my computer or the software i bought. I have a Macbook pro mid-2009 with the
    Hitachi HTS545050B9SA02 Media. I dont understand what rpm i have...???? It needs to be 7200 for adobe  cs6 production premium. Ive tried to download the sofware and it fails.. I'm tearfully trying to understand if it is my computer that cannot dowload the software or is it the software that is faulty. PLEASE HELP THIS COMPUTER ILLITERATE FOOL.

    cfoot wrote:
    I have a Macbook pro mid-2009
    Hitachi HTS545050B9SA02 Media.
    I dont understand what rpm i have...????
    Revolutions Per Minute (RPM) of that model of hard drive is 5,400, not 7,200.
    HITACHI TRAVELSTAR 5K500.B HTS545050B9SA02 500GB 5400RPM 8MB CACHE 9.5MM SATA 3Gb/s NOTEBOOK HARD DRIVE
    http://www.harddriveexperts.com/HTS545050B9SA02.html
    It needs to be 7200 for adobe cs6 production premium.
    I've never heard of such a thing.
    Usually the software installs regardless of drive performance, it's just slower on a stock 5,400 drive and I fail to see why Adobe would deny all the Mac users the ability to install Cs6 based upon this limitation.
    Most Mac's came with 5,400 RPM laptop drives as they take less power.
    Ive tried to download the sofware and it fails.. I'm tearfully trying to understand if it is my computer that cannot dowload the software or is it the software that is faulty.
    It should be able to download, the software won't know what speed of the drive is until the software is run.
    I would look at a slow, hobbled or data capped Internet connection or some other issue as your problem.
    Contact the vendor, it's their money your giving them, let them solve your problem.

  • I have an ipod 2g , The keyboard won't work! Or at least some of it's letters and numbers won't. please help i'm stuck with emojis

    i have an ippd touch 2g , a part of my keyboard won't work , i can type letters but i can't type numbers . please help i'm stuck with emojis keyboard

    Try restarting the iPod by holding down the lock and home button together and then slide the power button to turn it off and then wait 10 seconds and start it up again. If it is not a reset issue then it may be a hardware issue. Is your iPod damaged or have you dropped it recently? If it is a hardware problem then you may not be able to fix it. If your iPod has multitasking options like the new iOS devices, close out the app and then try again, it should reset your device to letters instead of emojis.

  • Please help me, How to connect my printer Canon pixma MP160 to my mac OS X Yosemite?

    please help me, How to connect my printer Canon pixma MP160 to my mac OS X Yosemite?

    You do not need the Setup Assistant; in fact, you do not need any software on an external hard drive. I have two LaCie's; I erased the drive as soon as I plugged it in. You will need to format it anyway because most hard drives come Windows formatted. So, if you only want to use it with the Mac, highlight it in Disk Utility and choose Mac OS Extended (Journaled) as the format and the GUID Partition scheme under Options. While doing that, it will erase the drive (and get rid of the LaCie software) - once finished, your drive is ready to use for Time Machine or any other backup plans you have for it.

  • Someone please help this is getting irritating!

    how do I fix the system overload erra audio engin was not able to process all required data? someone please help this is getting irritating!

    You have a few options:
    1- Increase the Buffer Size in the Logic Devices Preferences to the maximum (1024)
    2- Freeze some Tracks with CPU intensive plugins
    3- Buy a faster computer
    Hope that helps
    Edgar Rothermich 
    http://DingDingMusic.com/Manuals/
    'I may receive some form of compensation, financial or otherwise, from my recommendation or link.'

  • I can't forcequit firefox and shutdown my computer, nor can I open up any other programs or applications. Does anyone know how to fix this? please help this poor soul.

    I can't forcequit firefox and shutdown my computer, nor can I open up any other programs or applications. Does anyone know how to fix this? please help this poor soul.

    You can force quit applications
    >Force quit
    if that does not work you can force quit a computer shut down by hold the power button for an extended period.

  • I have windows 7 and every time I try to play or add a song. It says itunes has stopped working. Please help this is frustrating.

    I have windows 7 and every time I try to play or add a song. It says itunes has stopped working. Please help this is frustrating.

    a further message  box states that Data Execution Prevention has closed the program.
    Try updating your QuickTime to the most recent version. Does that clear up the DEP errors in iTunes?

  • HT1339 my ipod nano 7th generation....works fine as long as it's on the docking station. when off the station, the display goes dark after a few seconds. it's fully charged. please help. this is the heartbeat of my business. thanks

    my ipod nano 7th generation....works fine as long as it's on the docking station. when off the station, the display goes dark after a few seconds. it's fully charged. please help. this is the heartbeat of my business. thanks

    In the worst case, it's still under warranty (all 7th gen nanos are still under one year from purchase).
    So, you disconnect it from power, and it almost immediately goes dead?  You can try a Restore... but it doesn't sound like the type of problem a Restore will fix.
    You should probably have it looked by Apple Tech Support.  If there's an Apple Store nearby, you can take it to the store's Genius Bar.  To avoid waiting, you can make a reservation at the store's web page
    http://www.apple.com/retail/

  • My Iphone 4s Will not delete the songs I want it to. I've tried Turning off "Show All Music" and then swiping left on the song to delete it, but it wont give me the option to delete the songs. Please help. (this is iOS.7 btw)

    I've tried Turning off "Show All Music" and then swiping left on the song to delete it, but it wont give me the option to delete the songs. Please help. (this is iOS.7 btw) It only does this for some of the songs, but the rest of them I can delete. This is really annoying, please help me ASAP. Thank yall for your time

    I've tried Turning off "Show All Music" and then swiping left on the song to delete it, but it wont give me the option to delete the songs. Please help. (this is iOS.7 btw) It only does this for some of the songs, but the rest of them I can delete. This is really annoying, please help me ASAP. Thank yall for your time

  • HT204053 I have a just purchased my first iPod touch and i cannot transfer my music from my laptop to the iPod. The sync button doesn't appear to work.  What am i doing wrong? Please help this frustrated Grandma. I am trying to keep up with technology!

    I have just purchased my first iPod touch and I cannot transfer my music from my laptop. The sync button does not appear to work. What have I done wrong? I am a grandma trying to keep up with technology please help.

    Connect it to your computer and restore it as a new device. Then chose what music you want to sync with it and do so just like your Touch does.

Maybe you are looking for

  • Problem with SAPConsole Logon

    Hi; We are using SapConsole for using with a barcode reader, in the browser it shows the logon screen, when we type the user and password and then click the ok button, it stays in the logon screen. we already check the sapgui configuration and is ok.

  • Springboard exc crash

    i downloaded a tweak and after that my ipad is respring for all the time...all i can see is apple logo..i even restarted it with home button and on/off button( by holding them for 30 secs) after that i connected the ipad to pc and with itools i found

  • How to Cancel restrictions of Dates input box must input?

    when I Create  a activity , On tab Dates , I must Input "From to" "End to", This Type date is Configurated use SPRO. If I do not Input ,It will gives Error messages. How can i cancel this restrictions?

  • Can't see a portlet

    We have a page, published as portlet on a internet site (ACESS for portlet: not diplayed to public users; but the page is displayed to public) with a link to intranet site. The problem is that I, as a portal admin can view this portlet, but others wi

  • Connection problems with FCE HD and a Canon XL1

    I just can not get the system to see the camera so I can capture. I have an external Firewire drive as my scratch disc. Any advice? Thanks!