• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

assign a bean value to a string

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to assign a bean value to a string...
i am using this code


String s="<%= beanid.getProperty()%>";

but it is giving me an error... someone help please
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you provide a little more information?
 
vikhyath reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot for your reply ....


<%@ page language="java" import="java.sql.*"%>
<body>
<jsp:useBean id="SBean" scope="request" class="vikhyath.StudBean">
<jsp:setProperty name="SBean" property="*" />
</jsp:useBean>
The details you have entered are : <BR><BR>

Name : <jsp:getProperty name="SBean" property="name" /><br>
ID : <jsp:getProperty name="SBean" property="id" /><br>
Branch : <jsp:getProperty name="SBean" property="branch" /><br>
Marks : <jsp:getProperty name="SBean" property="marks" /><br>
Attendance : <jsp:getProperty name="SBean" property="atten" /><br><br><BR>
<%
String s="<%= SBean.getName() %>"; // ERROR !!! i want to assign a bean //property to a string so that i can use it in a session to insert the data //into mysql !
String name=request.getParameter("name");
String sid=request.getParameter("id");
String branch=request.getParameter("branch");
String marks=request.getParameter("marks");
String atten=request.getParameter("atten");
String pass="student";
try {
Statement stmt;
Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost:3306/vikh?user=root&password=admin";

Connection con =DriverManager.getConnection(url);

stmt = con.createStatement();


stmt.executeUpdate("insert into studb values ('"+name+"','"+pass+"','"+sid+"','"+branch+"','"+marks+"','"+atten+"');");
out.println("Updation successfull !");



con.close();
}catch( Exception e ) {
e.printStackTrace();
}%>
<pre><form action="front_store.html"><br>
<input type="submit" value="Enter New">
</form>
</body>
</html>
 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




it should bave been like

[ December 08, 2008: Message edited by: Sri Anand ]
 
vikhyath reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maaaaaaaan thanks a lot... thank you very very much.. i cant thank you enough... i was going mad over this for a week now.. Sri Anand YOU ROCK !! ... i am a newbie so still learning ! Prateek thanks to you too
 
Aum Tao
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad, we could help.
 
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic