Link to home
Start Free TrialLog in
Avatar of annasfe
annasfe

asked on

problem with wml and jsp

Ok, here is my problem.
First of all I try to browse a jsp page that gives wml from nokia browser and i get the famous "Server 500 error". I would guess that I have sth wrong with the code but the same page runs correctly under the gelon.net emulators. So what is wrong with the Nokia? Doesnt accept .jsp pages?

Second, I try to pass parameters from an index.wml page to a validate.jsp page that will do the validation. The problem is that the values never get to the jsp page correct, when i do an out.println in order to see what i got the value of the parameter is "undefined"! Can anyone help me?

here is the code:

index.wml page

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>
<!-- THIS IS THE FIRST CARD IN THE DECK -->
<card id="LoginCard" title="Login">
<p align="center">
WAP Login
</p>
 <p align="left">
      Login ID: &nbsp;
      <input name="telefono" value=""/><br/>
 </p>
 <p align="left">
      Password:
      <input type="password" name="password" value=""/>
 </p>
 <do type="accept" label="SUBMIT">
    <go method="post" href="validate.jsp">
        <postfield name="telefono" value="$(telefono)"/>
        <postfield name="password" value="$(password)"/>
    </go>
</do>
</card>
</wml>

____________________________________________________
the validate.jsp page


<%@ page contentType="text/vnd.wap.wml"%>
<?xml version=\"1.0\"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*" %>

<%
String username= request.getParameter("telefono");
String password = request.getParameter("password");
String pwd="";
String userid = "";
%>
<wml>
<card id="validation" title="Validation">
<%
if(username.equals("")||password.equals(""))
{
%>
<p align="center">
<b>
 The user name or password was not correct
</b>
</p>
<%
}
else
{
out.println(username);   /**here is where I check to see the values and I get the "undefined"
out.println(password);

Class.forName("org.gjt.mm.mysql.Driver");
Connection conn5 = DriverManager.getConnection("jdbc:mysql://......");
PreparedStatement PStmt = conn5.prepareStatement("select password,id from people where telefono= ?");
PStmt.setString(1,username);
ResultSet rs = PStmt.executeQuery();

while (rs.next()) {
pwd = rs.getString(1);
userid = rs.getString(2);
}

if (password.equals(pwd)) {
%>

<jsp:forward page="menu.jsp">
  <jsp:param name="userid" value="<%=userid%>"/>
</jsp:forward>

<%
}else{
%>
<p align="center">
<b>
 The user name or password was not found in database
</b>
</p>
<%
}
}
%>
</card>
</wml>



Another thing, is it possible to do this <jsp:forward> now that I have the wml? If not how can I automatically redirect user to the main page if the validation is correct?
Thanks for your help.
ASKER CERTIFIED SOLUTION
Avatar of jimmack
jimmack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of annasfe
annasfe

ASKER

First of all thanks a million Jimmack for putting so much time on it :)

I tried adding your changes to my code and at the beggining I though it worked but then...nothing, it worked only if I was putting the correct username and password, all the other cases (wrong username-password or null) I get server error.
Then I copied the code you send me and although I dont see what is so different with mine...... IT WORKS!!! :)  It must be the imports at the beginning or the way you set the response type, I dont know. Anyway I added the database thing in your code and it seems to work perfectly and the jsp:forward too! Just a commned, in your code you didnt add the null checking that you suggested before.

Anyway, thanks again, you are the best ;)
>>  in your code you didnt add the null checking

I know.  I was thinking about that after I went to bed ;-)  So long as you realised that and found it that's the important thing ;-)