• 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:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

datearray

 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a dropdownlist for quaterly months where q1=jan,feb,mar
q2=apr,may,june

.....etc

<code>
<OPTION <%= getSelectionQuaterly(0)%>value="1">
Q1
</OPTION>
<OPTION <%= getSelectionQuaterly(1)%>value="2">
Q2
</OPTION>
<OPTION <%= getSelectionQuaterly(2)%>value="3">
Q3
</OPTION>
<OPTION <%= getSelectionQuaterly(3)%>value="4">
Q4
</OPTION>
</select>

<select name="month" size="1">
<option <%=getSelectionMonth(0)%> value="1">
Jan,Feb,Mar
<option <%=getSelectionMonth(1)%> value="2">
Apr,May,Jun
<option <%=getSelectionMonth(2)%> value="3">
Jul,Aug,Sep
<option <%=getSelectionMonth(3)%> value="4">
Oct,Nov,Dec
</select> </code>
If I say int quetrly = request.getParameter("quaterly");
I am not getting the values
I need a validation for q1.
get the values in month= request.getparameter("month");

I want the values to be month =1,2,3

so that I can write a query where month(1,2,3).(ie check for quaterly)
 
Sheriff
Posts: 67759
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know why you insist on deleting and reposting this same question. Please stop.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If I say int quetrly = request.getParameter("quaterly");


request.getParameter returns a String, not an int.
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that was typeo. I mean
quaterly = Integer.parseInt(request.getParameter("quaterly"));

I would like to know how would I validate quaterlydates in jsp or java to return months for Q1 to check firstquater(jan,feb,mar).

Is it possible, Basically in jsp if i say <select name = month...>


month = Integer.parseInt(request.getParameter("quaterly"));

I have to get values for month as 1,2,3
[ March 10, 2008: Message edited by: lakshmi manepally ]
 
Bear Bibeault
Sheriff
Posts: 67759
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by lakshmi manepally:
that was typeo.


Please read this.
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I am not aware of this. Thanks for letting me know.
 
Ranch Hand
Posts: 72
Scala Monad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried the obove code in jsp. I got this error

Syntax error, 'for each' statements are only available if source level is 5.0
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have modified the code as below and it worked. But I want to pass to my query as month=1,2,3 at the same. How is it possible? Please let me know

<code>
int[] months = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int[] quarterMonths = new int[3];
WebDataAccess wda = new WebDataAccess();
int quarter = Integer.parseInt(request.getParameter("quarterly"));//'quarter' possible values - 1, 2, 3, 4
System.arraycopy(months, (quarter - 1) * 3, quarterMonths, 0, 3);//Now 'quarterMonths' array will hold the months for that quarter
for ( int month1=1; month1<=quarterMonths.length; month1++)
{ //System.out.print("month1:" + month1 );
System.out.println("Quat" +quarter);

System.out.println("quartermonths" +quarterMonths.length);
ht = wda.getInfoForThequater(category,month1,year);

} </code>
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have modified the code below, it worked. But I want to pass the month1 as 1,2, 3 at the same time to the below query.Please let me know

<code>int[] months = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int[] quarterMonths = new int[3];
WebDataAccess wda = new WebDataAccess();
int quarter = Integer.parseInt(request.getParameter("quarterly"));//'quarter' possible values - 1, 2, 3, 4
System.arraycopy(months, (quarter - 1) * 3, quarterMonths, 0, 3);//Now 'quarterMonths' array will hold the months for that quarter
for ( int month1=1; month1<=quarterMonths.length; month1++)
{ //System.out.print("month1:" + month1 );
System.out.println("Quat" +quarter);

System.out.println("quartermonths" +quarterMonths.length);
ht = wda.getThequaterReport(category,month1,year);

}</code>
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would I pass month1 as 1,2,3 to the below method where month is integer, I can't pass as array.
ht = wda.getquat(String cat, int mon, int year)

Please let me know the solution
 
Ranch Hand
Posts: 225
Spring Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot pass 1,2,3 to the method having int datatype.
If this method is mutable,then you can make it String datatype
And then by joining the array values with ,(comma) separtor and passing it to your method wda.getquat()

i.e instead of using wda.getquat(String cat, int mon, int year)
use, wda.getquat(String cat, String mon, int year)

"Chasing after impossible, you lose what is possible."

Regards
Baseet Ahmed
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you me some example please?
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic