Hi all,
I am trying to retreive information from datbase and baed ont the information i retreived i wanted to CHECK the radio button on the HTML The code goes like this
<%@ page import="Profile.Student" %>
<
jsp:useBean id="s" class="Profile.Student" scope="request"/>
<html><HEAD><body>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.io.*" %>
<%@ page session="true"%>
<%String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc
dbc:Resume";
String userId = (String)session.getAttribute("Ssn");
Class.forName(driver);
Connection con=null;
try{
con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
String query="SELECT * FROM Profile WHERE Ssn="+userId;
ResultSet rs=stmt.executeQuery(query);
while(rs.next()){
int ssn=rs.getInt(1);
String lastName=rs.getString(2);
String firstName=rs.getString(3);
String email=rs.getString(4);
String gender=rs.getString(5);
String degree=rs.getString(6);
String major1=rs.getString(7);
String major2=rs.getString(8);
String graduationDate=rs.getString(9);
String authorization=rs.getString(10);
String jobType=rs.getString(11);
double gpa=rs.getDouble(12);
String skills=rs.getString(13);
%>
<form action="ProfileEditSubmit.jsp" method="POST">
<input name="gender" type="radio"
value="MALE" <%=s.isGenderSelected("<%=gender%>")%>>
<input name="gender" type="radio" value="FEMALE"
<%=s.isGenderSelected("<%=gender%>")%>>
<input name="degree" type="radio"
value="MASTERS" <%=s.isDegreeSelected("<%=degree%>")%>>
<input name="degree" type="radio" value="BACHELOR"
<%=s.isDegreeSelected("<%=degree%>")%>>
<%
}
rs.close();
rs=null;
stmt.close();
stmt=null;
}
finally{
if(con!=null){
con.close();}
}
%>
</body>
</html>
The methods isGenderSelected and isDegreeSelected, i am trying to acess from Bean class.
The code for those methods are as follows
public String isJobTypeSelected(String s){
return (jobType.equals(s))? "checked" : "";
}
public String isGenderSelected(String s) {
return (gender.equals(s))? "checked" : "";
}
Well i am getting the following error if am trying to use.
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:165: ')' expected.
out.print(s.isGenderSelected('"<%=gender);
^
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:171: String not terminated at end of line.
out.print(s.isGenderSelected("<%=gender);
^
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:177: String not terminated at end of line.
out.print(s.isDegreeSelected("<%=degree);
^
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:183: String not terminated at end of line.
out.print(s.isDegreeSelected("<%=degree);
So my question is , how will i be able to pass the variable in the method <%=s.isGenderSelected("<%=gender%>")%>
I would really appreciate ur help
Regards,
vikram