rafael muneton

Greenhorn
+ Follow
since Aug 16, 2015
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by rafael muneton

Thank you Rob and Tim.
I will follow your recommendations, will replace scriplets with JSTL tags and later i will go for a controller servlet.

Anyway i will keep you posted.

Thank you guys.

Rafael
11 months ago
I don't know if this is the right place for my question, if this is not, please redirect me to the right one.

From some place in the web i copied the stuff to connect to Mysql using a DataSource and tried to adapt to my application.
It doesn't work.
I am using Tomcat 9.0.10, Mysql 5.7.

The problem is i am receiving 2 errors and i think they are the result of a bad connection.

Here are the errors:

25-Aug-2018 06:30:22.756 SEVERE [http-nio-8080-exec-7] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [jsp] in context with path [/agenda] threw exception [Unable to compile class for JSP:

An error occurred at line: [17] in the jsp file: [/validate.jsp]
rsAgenda cannot be resolved
14:      <sql:param value = "${password}" />
15: </sql:query>  
16:
17: <% if (rsAgenda.size() != 1) { %>
18:   <ora:redirect page="login.jsp" >
19:    <ora:param name="errorMsg" value="Clave de Usuario y/ Password son invalidos" />
20:   </ora:redirect>


An error occurred at line: [25] in the jsp file: [/validate.jsp]
rsAgenda cannot be resolved
22: <%--
23: Crea una userJavaBean y la guarda en session scope.
24: --%>
25: <% Row oneRow = (Row) rsAgenda.firstElement(); %>
26: <jsp:useBean id="validUser" scope="session" class="com.ora.jsp.userJavaBean" >
27: <jsp:setProperty name="validUser" property="usuario" value='<%= oneRow.getString("usuario") %>' />
28: <jsp:setProperty name="validUser" property="password" value='<%= oneRow.getString("password") %>' />


Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP:

And here is the validate.jsp  program:



The context.xml:[/u]

<Resource name="jdbc/Mysql1" auth="Container" type="javax.sql.DataSource"
              maxTotal="100" maxIdle="30" maxWaitMillis="10000"
              username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/javatest?serverTimezone=UTC&useLegacyDatetimeCode=false&time_zone='+00:00'"/>

[b]The web.xml:[/b]

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
   version="2.4">
 <description>MySQL Agenda App</description>
 <resource-ref>
     <description>DB Connection</description>
     <res-ref-name>jdbc/Mysql1</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
 </resource-ref>
</web-app>

Any ideas?
Any help is welcome.

Sincerely,
Rafael


11 months ago
OK guys:

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

Negrazo
4 years ago
JSP
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
4 years ago
JSP
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.
4 years ago
JSP