aspose file tools*
The moose likes JSP and the fly likes Problem integrating Input box with JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem integrating Input box with JSP" Watch "Problem integrating Input box with JSP" New topic
Author

Problem integrating Input box with JSP

vikram nalagampalli
Ranch Hand

Joined: Oct 08, 2001
Posts: 91
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
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

<input name="gender" type="radio"
value="MALE" <%=s.isGenderSelected("<%=gender%>")%>>

I don't think this is a valid construct.
I would do it this way:

Anyone else?....can qualify this pl.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
vikram nalagampalli
Ranch Hand

Joined: Oct 08, 2001
Posts: 91
hi,
I tried it but, its now shpwing a different error, amy more suggestion pls.
I would appreciate some other logic, if u can help me with to check the radio button depending upon the database.

The error i am getting is the following
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:165: String not terminated at end of line.
out.print(s.isGenderSelected(");
^
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:166: ')' expected.
// end
^
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:171: String not terminated at end of line.
")
^
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:177: String not terminated at end of line.
out.print(s.isGenderSelected(");
^
C:\tomcat\work\localhost_8080%2Ftorch\_0002fprofileEdit_0002ejspprofileEdit_jsp_0.java:183: String not terminated at end of line.
")
^
Thanks in advance
Vikram
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem integrating Input box with JSP