• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Pretty Basic but help needed

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This might be pretty simple for some of you so sorry if its boring. Here is my question. I have a JSP that I submit two pieces of information via a form, the form should go to the servlet that servlet will take those two pieces of information and return a result either a string or null 0 result. It should then return the result to the JSP, or email that result.

Not sure this works, I keep get null as a value on a query that I know should return something.

##################################################################
public class PasswordReminder implements java.io.Serializable {

public String ForgottenReminder;

public PasswordReminder() {}

public String getPassword(int Type, String Input) throws DataLayerException {
Connection Connection = null;
Connection = ConnectionFactory.getConnection();
int type = Type;
String input = Input;
synchronized(Connection) {
try {
Statement Statement = Connection.createStatement();
if (type == 1) {
ResultSet rs = Statement.executeQuery("SELECT password FROM customer WHERE email='"+input+"'");
ForgottenReminder = rs.getString(1);
rs.close();

} else {
ResultSet rs = Statement.executeQuery("SELECT password FROM customer WHERE customernumber='"+input+"'");
ForgottenReminder = rs.getString(1);
rs.close();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
return ForgottenReminder;
}

public String getPasswordReminder() {
return ForgottenReminder;
}
}
###############################################################

###############################################################
<jsp:useBean class="com.gc.present.PasswordReminder" id="password" scope="session"></jsp:useBean>

<form method="post" "enctype="multipart/form-data" action="password.jsp">
<input type="hidden" name="useage" value="admin">
<input type="text" name="input"><br>
<select name="type">
<option value="1" SELECTED>E-mail</option>
<option value="2">Customer Number</option>
</select>
<input type="submit" name="submit" value="submit">
</form>
<%
if (request.getParameter("submit") != null) {
%>
Password: <%= password.ForgottenReminder %>
<%
}
%>
############################################################
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Java Ranch!

Result sets start positioned before the first row, even when the query returns only one result.

try adding:



...also, Java canvention calls for the variable ForgottenReminder to be forgottenReminder -- note that lower case 'f'. Not a syntatic issue, but semantically Java programmers will look at "ForgottenReminder" and think that it's a class or something.

Also, just to point out the handy feature of CODE tags. Enclose your code with [CODE] and [/CODE] tags, and it will look like the code above.
 
Timy McTipperstan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tips.
I made the adjustment that you suggested, however I still get a null value
 
Timy McTipperstan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it! Thanks
 
Lookout! Runaway whale! Hide behind this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic