This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

jsp expressions doubt ???  RSS feed

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
------------------------------------------------
String username = request.getParameter("user");
String passwd = request.getParameter("pwd");


s.executeUpdate("insert into login values ( %>
<%= username %> <%,%> <%= passwd %> <% )"); %>
------------------------------------------------
this code gives me the following errors ....
------------------------------------------------
String not terminated at end of line.
s.executeUpdate("insert into login values (
^
')' expected.
// end
^
String not terminated at end of line.
)");
^
3 errors
-------------------------------------------------
could anyone please help me out with this ... or suggest another way to solve this problem
thankx in advance
SAmith
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you line is :
s.executeUpdate("insert into login values ( %>
<%= username %> <%,%> <%= passwd %> <% )"); %>
you are using direct java syntax in <% %>(this is in a jsp page right). you only use <%=%> to print the value out to the browser screen.
so this link should be:
<%s.executeUpdate("insert inot login values( " +username = ", " + passwd); %.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samith,
Please try to do this way and let's see.
[code]
<%
String username = request.getParameter("user");
String passwd = request.getParameter("pwd");
StringBuffer cmdBuff = new StringBuffer();
cmdBuffer.append("INSERT into login (UserName,Password) ");
cmdBuffer.append(" values (");
cmdBuffer.append(userName);
cmdBuffer.append(" , ");
cmdBuffer.append(passwd);
cmdBuffer.append(" )");
s.executeUpdate(cmdBuffer.toString());
%>
Note that I assumed in this following portion of cmd , 'UserName' and 'Password' are the exact field names (case sensitive) of your table named 'login' in your db! So if different change it accordingly!
"INSERT into login (UserName,Password) ")
There could be some syntax errors in java statements. Please check. I haven't executed this code. But you get the idea.
regds
maha anna
 
Samith Nambiar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Cynthia and maha .... i'm new to JSP and this is my first posting in this section of Javaranch .... your answers have very much cleared my doubt.
SAmith.P.Nambiar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!