java - Getting return value in JSP -


below code auto generate purchase order number mysql database in jsp. want return "pono" string shows error because outside if condition.

how can string return?

<%!     public string autopono()throws sqlexception{          rs=pst.executequery();          if(rs.next()){             string po= rs.getstring("max(pono)");             int intno = integer.parseint(po);             intno+=1;              string pono = integer.tostring(intno);           }             return pono;       } %> 

declare variable otsido of loop:

<%!     public string autopono()throws sqlexception{                string pono = null;                 rs=pst.executequery();                  if(rs.next()){                    string po= rs.getstring("max(pono)");                    int intno = integer.parseint(po);                    intno+=1;                     pono = integer.tostring(intno);                   }             return pono;          }     } %> 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -