This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Displaying all the months in the year Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying all the months in the year" Watch "Displaying all the months in the year" New topic
Author

Displaying all the months in the year

venkatesh padmanabhan
Greenhorn

Joined: Feb 17, 2006
Posts: 20
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

Joined: Jan 10, 2006
Posts: 62

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


Regards,Vinny M.
proud Fan of European Champion CHELSEA FC
"If you don't see the bug where you're looking, perhaps you're looking in the wrong place" -James Gosling
venkatesh padmanabhan
Greenhorn

Joined: Feb 17, 2006
Posts: 20
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

Joined: Jan 10, 2006
Posts: 62

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

Joined: Jan 10, 2006
Posts: 62

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

Joined: Feb 17, 2006
Posts: 20
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

Joined: Feb 19, 2006
Posts: 5
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 ]

Jon Emerson<br /> <a href="http://www.jonemerson.net" target="_blank" rel="nofollow">http://www.jonemerson.net</A>
venkatesh padmanabhan
Greenhorn

Joined: Feb 17, 2006
Posts: 20
I need to display the months in horizontal way, not vertically
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying all the months in the year
 
Similar Threads
user selection of multiple items?
To change color,when user selects a date?
changing the color?
table problem?
Problem with saving a state in calendar program.