• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Displaying all the months in the year

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a calendar in jsp. when the user enters the year, it should display all the 12 months, but am getting a single month 12 times.. please verify the code and help..

 
Ranch Hand
Posts: 63
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Venkatesh,
One question:
is there a need to put so much java code in the jsp?
i would suggest it is better to do the processing in a java class(servlet) and use the jsp for only view purpose.

cheers
thanks
vinny m
 
venkatesh padmanabhan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was asked to create a calendar in JSP,rather than using seperate java page.. Please help with my query of displaying all the months..
 
Vinny Menon
Ranch Hand
Posts: 63
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Venkatesh,
i would still suggest that it is not a good practice for having so much java code in jsp.
However also see the following points in ur code:
which is why it is printing only a single month:
1.what is the need for this loop

2.
You are creating only one instance of calendar and then using the same in the for loop


check this out:i have made some major changes to your code and this will work:




hth,
cheers
vinny m
 
Vinny Menon
Ranch Hand
Posts: 63
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey
further improvements to your code:


this will work properly.
cheers
vinny m

[ February 17, 2006: Message edited by: Vinny Menon ]
[ February 17, 2006: Message edited by: Vinny Menon ]
 
venkatesh padmanabhan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can u help me use buttons in the code, instead of the plain numbers being shown..


where should i insert this button in the calendar code? when i tried using, am getting the buttons as well as the plain numbers.

I also need to display the calendar in horizontal manner, rather than in the vertical manner?

please help.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys, you don't need to define the months of the year or the days in a month yourselves -- The Calendar object will do it for you . In addition, <td> tags need to be terminated by </td> tags!

I've fixed both these things in my simplification of CalendarPage.jsp:



Enjoy
[ February 20, 2006: Message edited by: Jon Emerson ]
 
venkatesh padmanabhan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to display the months in horizontal way, not vertically
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic