aspose file tools*
The moose likes JSP and the fly likes Java Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Java Help" Watch "Java Help" New topic
Author

Java Help

rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
I have a application where if the employee has not updated for month of January than he should not be allowed to update for month of June.If he does he should get a msg saying that he should first update for Jan.How to do this using java and jsp?
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
i think the question should be more clear.specify what to update,how to update and where to update.
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
I am doing an application where leave of employee will be updated every 6 months.Now i am doing all this properly in java .The user cant update for month of june until he updates for january.Code wise this is working fine.But now i want to display msg to user that he should update for january first.In Jsp i want to check the last updated month from database and display.If any queries pls ask.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
Rose,
I m not 100% sure abt your question still I will take a chance,
As you want to ceck for month in DB,u might have a feeld called date or month in DB say dbMoth,and there must be some input field in ur form which collects Date or month say frmMonth.So try doing this,

ResultSet rs=st.executeQuery("select max(dbMonth) from mytable where ........");
stempMoth=request.getParameter("frmMonth");
if(rs.next())
{
stempMonth=rs.getString(1);
}
if( ( Integer.parseInt(supdateMonth)-Integer.parseInt(stempMonth)!=0 )
{
out.println("You must First .........");
}
else
your update logic

here i have not concentarted on execption handeling,
just tried to explain the logic.
feel free to ask question ,if any.
cheers
Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
You r right.But then i have written a function in java to calculate max month and year stored in database.
Its like this...
public int max_year() throws SQLException
{
System.out.println("MAX YEAR.... dfbgjkdhfghdfkl");
int yer=0;
ResultSet rsleavetype;
sttnew = con.createStatement();
try{
strsql="select max(for_year) from transaction";


rsleavetype=sttnew.executeQuery(strsql);
if(rsleavetype.next())
{
yer=rsleavetype.getInt(1);
System.out.println("MAX YEAR...."+yer);
return yer;
}
else
return yer;
}catch(NullPointerException e)
{
System.out.println("No year");
return yer;
}

}
---------
same code goes for month..but than while i have to display using jsp i am writing
<%
String month = leaveUpdates.max_month();
int year = leaveUpdates.max_year();

%>
Last Updated Month <%=month%><br>
Last Updated Year <%=year%><BR><br>
.....
which is giving me null pointer exception and not the value.
Pls help...and ask queries if any..
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
looking to ur method i guess nullpointer is thrown at time of createing statment cause ur connection object might be null,this is just an wild guess.A
nd plz be specifec with ur questions like
where is error displayed,in java or jsp page?
also if u post your function of month and the error message,it will be more helpful to understand ur problem.
And As u have try catc block already written then y is
sttnew = con.createStatement(); out of it ???
cheers
Praful
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Let me be clear now...hope u get it..!!Coz when i read my Q i myself get confused..hehe...jokes apart...!!Here is what i want..!
i have an application where i am calculating leave of employees every 6 months.My backend is Java with mysql database and front end is in JSP.
Now calculation is all complete in Java.
First time i update leave for January 2003.Now until i update in June 2002 i cant update for January 2003.Coding wise this is happening.But when user selects January 2003 i want a message displayed to user saying he cant update until he updates for June.
Hope u get this
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
still .
Now where is your Null Pointer Exception gon ??? if it is solved
and method returns max_year and max_month then what r u waiting 4 ???
simply put if conditions in jsp and dispaly message
int current_month= month from request
int current_year=month from request
int max_month= month from method
int max_year=month from method
depending on these values display mesasge backt to user !!!
get back if needed
Praful
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Thanx a lot.It worked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Help
 
Similar Threads
Suggestion for Java Ranch
Connecting Exel file to servers Acess DB file remotely
scheduling
multi month calendar
prep time for scjp 6.0