Ragini Shukla
ssttttrrrr
3 Answer(s)      8 years ago
Posted in : Java Beginners

Ads

View Answers

October 20, 2008 at 2:47 PM


Hi friend,


Plz give full source code to solve the problem.


For more information on session visit to :

http://www.roseindia.net/jsp/jsp-form-session.shtml


Thanks


October 20, 2008 at 4:57 PM


one.jsp
=======

TOT = TOT + rs.getInt("NUMOFCONLABENG");
<input type="hidden" name="Total" value= <%= TOT %>

two.jsp
--------

String CLSEC1 = request.getParameter("Total");

Here the value available , Now if u want it as integer then use type cast.



Thanks
Rajanikant


October 20, 2008 at 5:06 PM


Hi,

In session we can save objects only, but not the primitive data types.
session.setAttribute("CLSEC1", TOT);
TOT is a primitive data type so it cannot be saved.

check the alternate ways to save:

Way 1:
Save TOT as a String
session.setAttribute("CLSEC1", TOT+"");

and convert into int while accessing.
if(session.getAttribute("CLSEC1") != null){
Integer.parseInt(session.getAttribute("CLSEC1"));
}

Way 2:
Save TOT as an Integer Object
session.setAttribute("CLSEC1", new Integer(TOT));

and convert into int while accessing.
if(session.getAttribute("CLSEC1") != null){
((Integer)session.getAttribute("CLSEC1")).getInt();
}

Regards,
Sreekar















Related Tutorials/Questions & Answers:

Ads

Advertisement