Comparing results from a method using jsp
I want to check if my password check returns a row number of 1.
but I keep recieving this error in my jsp calling page.
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\jakarta-tomcat\work\localhost_8080_0002ftest_0002fadetest_0002fdatabase_0002fpassword_0005flogin_0005fform_0002fsubmitPassword_0002ejspsubmitPassword_jsp_1.java:108: No variable stmtInt defined in class java.lang.String.
if (pass.selectPassword().stmtInt.equals(1));
using this tag library
<jsp:useBean id="pass" class="classpath" scope="request">
<jsp:setProperty name="pass" property="*" />
</jsp:useBean>
I saw your other posting.
stmtInt is a local variable of a method. A local variable of a method expires when the method execution is completed.So you cannot do something like
selectPassword().stmtInt
Do the following
1. return int from selectPassword().
like
by doing
public int selectPassword()
instead of
public String selectPassword()
and by doing
return stmtInt
instead of
return "No fo rows found" + stmtInt
2. compare using ==
by doing
if (pass.selectPassword() == 1 );
instead of
if (pass.selectPassword().stmtInt.equals(1));
Similar Messages
-
How to compare result from sql query with data writen in html input tag?
how to compare result
from sql query with data
writen in html input tag?
I need to compare
user and password in html form
with all user and password in database
how to do this?
or put the resulr from sql query
in array
please help me?Hi dejani
first get the user name and password enter by the user
using
String sUsername=request.getParameter("name of the textfield");
String sPassword=request.getParameter("name of the textfield");
after executeQuery() statement
int exist=0;
while(rs.next())
String sUserId= rs.getString("username");
String sPass_wd= rs.getString("password");
if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
exist=1;
if(exist==1)
out.println("user exist");
else
out.println("not exist"); -
How to store and retrieve blob data type in/from oracle database using JSP
how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
thanksJSP? Why?
start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html] -
How to call java method using jsp
how to call java method using jsp.....
anyone can help me.....i having problem here...coz i very new in java and jsp.....
thanks.....keep an eye on this person's thread...they have code there and everything.
http://forum.java.sun.com/thread.jspa?threadID=777263&tstart=0 -
How to join the results from 2 webservices using BPEL?Architecture question
Hi,
I am new to BPEL. BPEL process calls two webservices, which return complex results. I need to process the results from 2 webservices using BPEL .The result will be a complex xml, join/merge of previous results.
What is the best practice to do it with BPEL?
I see three ways:
1.To do the processing (join/ merge) inside the BPEL process itself and return complex xml.
2.Develop auxiliary webservice in java. Auxiliary webservice will do the processing (join/merge). Call this webservice from BPEL process.
3.Do a plain concatenation of the two XMLs in BPEL and forward it to the frontend. Frontend then will do all the logic on its side
Thanks,
Borisyou could process the XMLs one at a time, and use XSL transformations to process the payload to a target schema.
Activity 1:
output from webservice1 -> transform 1 -> partial XML (of target schema)
Activity 2:
output from webservice2 -> transform 2 -> completed XML (of target schema)
Regards,
Shanmu. -
Odd results from SQL statement in JSP
Hi.
Getting very strange results from my SQL statement housed in my JSP.
the last part of it is like so:
"SELECT DISTINCT AID, ACTIVE, REQUESTOR_NAME, ..." +
"REQUESTOR_EMAIL" +
" FROM CHANGE_CONTROL_ADMIN a INNER JOIN CHANGE_CONTROL_USER b " +
"ON a.CHANGE_CTRL_ID = b.CHANGE_CTRL_ID " +
" WHERE UPPER(REQUESTOR_NAME) LIKE ? "; I've set the following variables and statements:
String reqName = request.getParameter("requestor_name");
PreparedStatement prepstmt = connection.prepareStatement(preparedQuery);
prepstmt.setString(1, "%" + reqName.trim().toUpperCase() + "%");
ResultSet rslts = prepstmt.executeQuery();
rslts.next();
int aidn = rslts.getInt(1);
int actbox = rslts.getInt(2); String reqname = rslts.getString(3).toUpperCase();
String reqemails = rslts.getString(4);
String bizct = rslts.getString(5);
String dept = rslts.getString(6);
String loc = rslts.getString(7);
Date datereq = rslts.getDate(8);
String busvp = rslts.getString(9);
AND SO ONSo then I loop it, or try to with the following:
<%
try {
while ((rslts).next()) { %>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
rslts.close();
selstmt.close();
catch(Exception ex){
ex.printStackTrace();
log("Exception", ex);
%>AND so on, setting 13 getXXX methods of the 16 cols in the SQL statement.
Trouble is I'm getting wildly inconsistent results.
For example, typing 'H' (w/o quotes) will spit out 20 duplicate records of a guy named Herman, with the rest of his corresponding info correct, just repeated for some reason.
Typing in 'He' will bring back the record twice (2 rows of the complete result set being queried).
However, typing in 'Her' returns nothing. I could type in 'ell' (last 3 letters of his name, Winchell) and it will again return two duplicate records, but typing in 'hell' would return nothing.
Am I omitting something crucial from the while statement that's needed to accurately print out the results set without duplicating it and that will ensure returning it?
There's also records in the DB that I know are there but aren't being returned. Different names (i.e. Jennifer, Jesse, Jeremy) won't be returned by typing in partial name strings like Je.
Any insight would be largely appreciated.
One sidenote: I can go to SQL Plus and accurately return a results set through the above query. Having said that, is it possible the JDBC driver has some kind of issue?
Message was edited by:
bpropes20
Message was edited by:
bpropes20Am I omitting something crucial from the while
statement that's needed to accurately print out the
results set without duplicating it and that will
ensure returning it?Yes.
In this code, nothing ever changes the value of reqname or any of the other variables.
while ((rslts).next()) { %>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
} You code needs to be like this:while (rslts.next()) {
reqname = rslts.getString(3).toUpperCase();
reqemails = rslts.getString(4);
bizct = rslts.getString(5);
dept = rslts.getString(6);
loc = rslts.getString(7);
datereq = rslts.getDate(8);
busvp = rslts.getString(9);
%>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
There's also records in the DB that I know are there
but aren't being returned. Different names (i.e.
Jennifer, Jesse, Jeremy) won't be returned by typing
in partial name strings like Je.Well, you're half-right, your loop won't display all the rows in the result set, because you call rslts.next(); once immediately after executing the query. That advance the result set to the first row; when the loop is entered, it starts displaying at the 2nd row (or later if there are more next() calls in the code you omitted). -
Deleting a row from a table using jsp
Given a table in a jsp, can an user click on a row of that table and retrieve the information so that the program can delete a record from a database table?
most of the tables that I have seen are static, the user cannot interact with them(specially when the user wants to delete several records from a database table).
Can anyone suggests a good book or way of deleting a row from table using jsp.eg use a column in the table that has a radio button or check box,
on submit, get all the rows that are checked, using the row as an index into your db store, get the key and use the key to issue the sql delete command. -
Uploading the file to server from the browser using JSP
I have facing difficulty while uploading the file from the browser using user interface to the server or to the database. As previousy i was working in coldfusion, i find it very easy there with cffile command, but i am confused how to do that in JSP
please reply soon, as i am stuck in my project because of that
SaroshCheck out http://www.jspsmart.com , They have a nice free upload api that can be used w/ JSPs or Servlets. I hear O'Reilly has a nice one too. May as well use someone elses if they've done it already.
-
Downloading xls sheet from application server using jsp page
hi,
I am creating an excel sheet and storing it in application server which runs on HP-UNIX OS. I want to download that excel sheet using jsp page. With the following code snippet i m able to access the jsp page, but i m not able to download xls sheet. its giving "the page cannot be found "error. Is there any other way to download the excel sheet from jsp page.
<%
out.println("<a href=\"./Download.xls\">Download excel</a>");
out.println("<a href=\"./Download.jsp\">Download jsp</a>");
%>
Thx in adv.
rituhref should be ur absolure path like
http://servername:8080/files/Download.xls"
pls try these and let me know
shanu -
Strange results from JDBC Query using a VARRAY
Here's one for you experts:
I have a 9i release 2 db set up, to which I connect via the JDBC thin
driver. I have a JavaServer Pages application that needs to read a VARRAY
from a table and then use the contents of the VARRAY. Here's the code in
the JSP that does that:
resultset=db.executeQuery
("SELECT IMAGE_lIST FROM PAGE_IMAGE_ARRAY WHERE PAGENAME = " +
pagename);
oracle.sql.ARRAY array =
((oracle.jdbc.driver.OracleResultSet)resultset).getARRAY(1);
imageList = (String[])array.getArray();
for(int count=0; count<imageList.length; count++)
out.println("<p>The image at position " + count + " in the array is
the image titled: " + imageList[count]);
The JSP compiles and runs fine, but the output is as follows:
The image at position 0 in the array is the image titled: 0x7465737431
The image at position 1 in the array is the image titled: 0x7465737432
The image at position 2 in the array is the image titled: 0x7465737433
The image at position 3 in the array is the image titled: 0x7465737436
A query using SQL*Plus verifies that the actual values of the elements of
the array are 'test1', 'test2', 'test3', 'test6'. Notice that the last
digit in the hex(?) output matches the last digit of the actual string.
What's causing this? It looks like a data type mismatch, but I would have
thought that such an error would have triggered a compile-time error.
Any help is greatly appreciated.
Regards,
Dave PennDave,
The following should help.
1 select rawtohex('test1') val1,
2 rawtohex('test2') val2
3* from dual
SQL> /
VAL1 VAL2
7465737431 7465737432
SQL> select rawtohex('1') val1,
2 rawtohex('2') val2
3 from dual;
VA VA
31 32 -
Printing a web page from the browser using JSP
Hi sir,
I want to know how to print a webpage that contains some
report data where the web page contains a button as well when i click the button only the webpage contents(report data) should be send to the printer and should be printed.Here i should not use any javascript.By using pure java code in Jsp i need to do this.Pls.provide the code for this so that i will be grateful to u.Where it is very Urgent.I will be waiting for ur reply.
Thanx,
m.ananthuIf you are reasonable sure that the user will be using a newer browser you could use the <LINK> tag to set an alternative print page. When the user clicks on the print button it calls a javascript funtion that does a window.print function call. The browser will then request the alternative print page and print this page instead of what is in teh browser.
This will require two JSP pages but with proper use of includes you can reuse the code.
Sorry I don't have any examples handy so you'll have to search the web but I know it works because I've done it for an intranet site. -
Getting Result from multiple table using code table.
I am having hard time getting data from different table not directly connected.
The data model is not proper. Why should you store the game details in separate tables?
IMO its just matter of putting them in same table with additional field gamename to indicate the game. That would have been much easier to query and retrieve results
Anyways in the current way what you can do is this
SELECT p.ID,p.Name,c.CategoryName AS [WinnerIn]
FROM GameParticipants p
INNER JOIN (SELECT ParticipantID, Value AS ParticipantName,'CGW Table' AS TableName
FROM CGWTable
UNION ALL
SELECT ParticipantID, Value AS ParticipantName,'FW Table' AS TableName
FROM FWTable
SELECT ParticipantID, Value AS ParticipantName,'WC Winner' AS TableName
FROM WCWinner
... all other winner tables
)v
ON v.ParticipantID = p.ID
AND v.ParticipantName = p.Name
INNER JOIN Category c
ON c.TableName = v.TableName
If you want you can also add a filter like
WHERE p.Name = @Name
to filter for particular player like Henry in your example
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to add results from a method
Hi-
I have written the following code that takes an input integer, and figures out every odd integer contained inside such as inputting 7 would give you 5,3,1. How can I modify this code to take those answers in my example and get it to add them to equal 9 in this case? I have tried making my method return an int, but I am doing something wrong, and have banged on this for hours, resulting in a giggling compiler. Even if I get some help on the return, I am baffled by how to get another method(?) or whatever to "remember" the parsed out odd integers
and then add them.
Thanks
Brad
public class OddSum
public static void main (String [] args)
System.out.println ("Please Enter An Integer.");
int varOne;
EasyIn easy = new EasyIn();
varOne = easy.readInt();
System.out.println("You Entered: " + varOne);
figureOdds(varOne);
public static void figureOdds (int varOne)
int num;
for (num = varOne-1; num >0; --num)
int monkees;
monkees = num;
if(monkees%2 != 0)
System.out.println("The Odds Contained in your Input Integer are: " + monkees);
}Hmmm-
neither of those solutioins are working correctly. Say for example I entered a 5. First (and what I had working)
I wanted to find all the odd ints contained in 5 not including 5: 3 and 1. THEN I wanted to add them for a result of 4. It was helpful to see that I could declare a var named sum and set it to 0 as in this:
int sumOfOdds = 0;
for (num = varOne-1; num >0; --num)
//int monkees;
//monkees = num;
if(num%2 != 0)
sumOfOdds += num;
System.out.println("The Odds Contained in your Input Integer are: " + num);
but when you compile and enter "11" as the int it comes up with 55 instead of 25 as it should.
In the second reply with code:
public static int figureOdds(int varOne) {
int num, sum = 0;
for (num = varOne-1; num > 0; --num) {
if(num%2 != 0){
sum += num;
System.out.println("The Odds Contained in your Input Integer are: " + num);
return sum;
it gives me the same result as I was getting. Am I missing something that was unsaid, but supposed to be understood?
Thanks
Brad -
How to read an image from an file using jsp
reading an image from an file present on local disk using jsp
Server-local or client-local? First, File I/O, second: better get a new job.
-
Populating my dropdown menu from MySQL database using jsp
I my database i have a table of users and i want everytime a user is added the dropdown menu gets updated, this is make updating of user's profile easy. I tried the one bellow but still get me 80 errors:
----connection String------
<select name="userName" id="userName">
<% for(int i=1; i<=resultsList; ++i){%>
<option value="<%=out.println(rs.getUserName(1))%>"><%=out.println(rs.getUserName(1))%></option>
<option value="<%=out.println(rs.getUserName(i))%>"><%=out.println(rs.getUserName(i))%></option>
<%}%>
</select>
Pls i need help80 errors, you say?
I'm not a fan of writing muddled jsp pages that refer to the database layer. If you're willing to learn JSF or some other web framework, you'll being able to write better code and never use a scriptlet again.
Maybe you are looking for
-
ISCSI connections for guests: how to set up?
A couple of questions: 1. If we wanted to set up iSCSI connections for guests such as SQL servers, what is the best way to handle this? For example, if we had four 10-Gb NICs and wanted to use as few of them as possible, is it common to turn two of t
-
Where are my photos? Old and new missing.
I'm not very tech savvy so I apologize in advance. But I recently signed up on icloud.com. Before this, I had to change my appleID in the photo stream (on my phone) because it wasn't matching. All is well after that except all of the old photos I had
-
How can i get skype video calling to work on my mini ipad
do need an additional webcam for skype calling
-
Reminders, When promising to recall a day I can not make it stop at a certain date?
Box (end) does not function properly once selected back to its former
-
Error code 6 on Rescue & Recovery 4.5
Hi, Theres a error code 6 on the installation process of R&R 4.5 on a win7 clean installation. Anyone knows whats the error about? (C++ is installed) Regards W530 2447-2EG W7 x64, T61p 6460-8WU W7 x64, T61 6460-65G W7 x64, T43 2668-F3G W7 x86.