This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!