Hi everyone, Can someone help me? I have 4 checkboxes... and in the HTML they look like this: <Input type ="Checkbox" name="jobType" value="FULLTIME">Fulltime <Input type ="Checkbox" name="jobType" value="PARTTIME">Parttime <Input type ="Checkbox" name="jobType" value="INTERN">Intern But when I process it with the JSP page and want to enter the chosen value as text, it inserts something like this: [Ljava.lang.String;@74bcf7 [Ljava.lang.String;@9fa8f Can someone please help me, as to why the values of the checkboxes are not inserted?? Thanks! CHARAN
Dmitriy Pavlyuk
Ranch Hand
Joined: Mar 25, 2001
Posts: 33
posted
0
Your problem is very strange. Symbols which you are get in the value is the memory link of your String object. Default when you output your string? the string value is outputing (method toString() is calling). May be you have another mistake in your code. Try to call method toString() actually, f.e. <%=yourString.toString()%>, but it's equal to <%=yourString%> if "yourString" has a String type.
Adam Hardy
Ranch Hand
Joined: Oct 09, 2001
Posts: 564
posted
0
perhaps if we saw the JSP we could tell?
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Sankar Bhamidi
Greenhorn
Joined: Nov 05, 2001
Posts: 5
posted
0
Thank you for your replies. Here is the relevant code in the java file and then the JSP page. Please help: public class Student implements java.io.Serializable{ private String[] jobType;
public Student(){ jobType=new String[] { "1" }; } public void setJobType(String[] jobType){ this.jobType=jobType; } public String[] getJobType(){ return jobType; } } The relevant JSP code is :
Herein lies your problem (see sections highlighted):
Originally posted by Sankar Bhamidi: public class Student implements java.io.Serializable{ private String[] jobType;
... public String[] getJobType(){ return jobType; } } The relevant JSP code is : ... String st= "insert into Profile values("+s.getSsn()+",'"+s.getLastName()+"','"+s.getFirstName()+"','"+s.getEmail()+"','"+s.getGender()+"','"+s.getDegree()+"','"+s.getMajor1()+"','"+s.getMajor2()+"','"+s.getGradua tionDate()+"','"+s.getAuthorization()+"','"+s.getJobType()+"','"+s.getGpa()+"','"+s.getSkills()+"')";
s.getJobType() returns a String[], not a String. Since concatenating strings will implicitly call the toString() methods for objects, Array.toString() will be called for a String[]. Suggested solution: Create another get method, say getJobTypeString(), that returns a String. This method will loop through this.jobType and build up the correct String you need. ------------------ Junilu Lacar Sun Certified Programmer for the Java� 2 Platform @#$!)?/# UBB formatting! [This message has been edited by JUNILU LACAR (edited November 09, 2001).] [This message has been edited by JUNILU LACAR (edited November 09, 2001).]