File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying all the months in the year

 
venkatesh padmanabhan
Greenhorn
Posts: 20
  • 0
  • 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..

 
Vinny Menon
Ranch Hand
Posts: 62
Java Oracle Spring
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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.
 
Jon Emerson
Greenhorn
Posts: 5
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to display the months in horizontal way, not vertically
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic