Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Displaying all the months in the year  RSS feed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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: 62
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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: 62
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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: 62
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
I need to display the months in horizontal way, not vertically
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!