• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with a login program

 
rafael muneton
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone:

I am trying to develop a small app just to learn Jsp and I have being stopped by a problem:

The error message I receive is :

An error occurred at line: 13 in the jsp file: /validate.jsp
equiposLog cannot be resolved
10: <ora:sqlStringValue param="password" />
11: </ora:sqlQuery>
12:
13: <% if (equiposLog.size() > 0) { %>
14: <jsp:forward page="mainmenu.html" />
15: <% } else { %>
16: <jsp:forward page="login.jsp" />
[i]
[/i]

It seems to be very simple, but not for me.
Here is the login.jsp program:

<%@ page language="java" contentType="text/html" %>
<%@ page import="com.ora.jsp.util.*" %>
<%@ taglib uri="/orataglib" prefix="ora" %>
<html>
<head>
<title>Proyecto LigaMX</title>
</head>
<h2>Proyecto LigaMX </h2>
<body bgcolor="#cccccc">
<img src="tareas02.jpg" height="80" width="40" align="center"/>

<jsp:useBean id="errorMessages" scope="request" class="java.util.Vector" />

<%-- Errores reportados, si los hay. --%>
<ul>
<font color="red">
<ora:loop name="errorMessages" loopId="msg" className="String" >
<li> <%= msg %>
</ora:loop>
</font>
</ul>

<B>Por favor teclee clave de Usuario y Password:</B>
<%-- Output form with submitted values --%>
<form action="validate.jsp" method="post">
<table>
<tr>
<td><B>Usuario:</B></td>
<td><input type="text" name="usuario"
value='<%= StringFormat.toHTMLString(request.getParameter("usuario")) %>' >
</td>
</tr>
<tr>
<td><B>Password:</B></td>
<td><input type="password" name="password"
value='<%= StringFormat.toHTMLString(request.getParameter("password")) %>' >
</td>
</tr>
<td colspan=2><input type="submit" value="Continuar"></td>
<td><input type="button" value="Atras" onClick="history.go(-2)"></td>
</tr>
</table>
</form>

</body>
</html>

And here is the validate.jsp program:

<%@ page language="java" contentType="text/html" %>
<%@ page import="com.ora.jsp.util.*" %>

<jsp:useBean id="errorMessages" scope="request" class="java.util.Vector" />

<ora:sqlQuery id="equiposLog" dataSource="jdbc/mysql2" scope="request">
SELECT nombre FROM usuario
WHERE user = ? and password = ?
<ora:sqlStringValue param="usuario" />
<ora:sqlStringValue param="password" />
</ora:sqlQuery>

<% if (equiposLog.size() > 0) { %>
<jsp:forward page="mainmenu.html" />
<% } else { %>
<jsp:forward page="login.jsp" />
<% } %>


As you can see the first program(login.jsp) is asking user and password.
The second program(validate.jsp) tries to find this data in a Database. If positive, the control will go to mainmenu.html otherwise will return to login.jsp.
I am using Tomcat 6 as a container and MySQL as Database.

I am stucked at this point and any help would be very welcome.

Thanks.
 
Tapas Chand
Ranch Hand
Posts: 600
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are learning JSP and I am afraid you are on wrong track.
Do NOT use scriplets in JSP.
They are obsolete since 13 years.
And JSPs are for view. No programming logic should be in them.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tapas, is very correct. You are writing JSPs as if it were still 2001. In 2015 JSPs should be written using the JSTL (JSP Standard Tag Library) and the EL (Expression Language). Please make sure your study materials are up to data and cover theses topics rather than putting Java code into JSPs.

I also recommend novices to JSP read the following:
  • The Secret Life of JSPs
  • The Front Man

  •  
    rafael muneton
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hello guys:

    I agree with you, the book i am reading is from the year 2001 and surely is obsolete, but for starters what can i do?
    I wil try to drop of the java code from the JSP's and see what happens.

    Thanks a lot.

    Sincerely,
    Negrazo
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 65519
    105
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    rafael muneton wrote:
    I agree with you, the book i am reading is from the year 2001 and surely is obsolete, but for starters what can i do?

    Find more up-to-date material. A book from 2001 is pretty much useless.

    I wil try to drop of the java code from the JSP's and see what happens.

    Well, you can't just drop the code and not replace it with its modern equivalent. You need to learn about the JSTL and EL. I'm sure that there are free online tutorials that you can find.
     
    rafael muneton
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    OK guys:

    I got the point I will try to stick to JSTL and ETL. I'll keep you posted.
    Thanks anyway.

    Negrazo
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!