• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem integrating Input box with JSP

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<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
 
vikram nalagampalli
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
get schwifty. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic