my dog learned polymorphism*
The moose likes JSP and the fly likes datearray Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "datearray" Watch "datearray" New topic
Author

datearray

phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
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)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

I don't know why you insist on deleting and reposting this same question. Please stop.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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

request.getParameter returns a String, not an int.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Originally posted by lakshmi manepally:
that was typeo.

Please read this.
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
Sorry, I am not aware of this. Thanks for letting me know.
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72



- Marimuthu Madasamy
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
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

Joined: Apr 06, 2005
Posts: 251
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

Joined: Apr 06, 2005
Posts: 251
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

Joined: Apr 06, 2005
Posts: 251
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
Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224
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

Joined: Apr 06, 2005
Posts: 251
can you me some example please?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: datearray