WAP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreWAP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 10th, 2004, 03:57 AM
zhenwe1 zhenwe1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 zhenwe1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Pass WML variables to Servlet

Hi Guys!

I have the following problem. I am using a servelt to write 2 cards (card login and card valid). I need to pass a variable from card login to card valid. But before I can pass the value in the variables to card valid, I need to pre-process them using Java. I tried posting the variables but this does not work. I always receive the values as "null" in the valid card. Could someone pls help me with this problem. Below is the Servlet code:

----------------------------------------------------------
package com.omh.wap;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class Convert extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

// Set the content type of the response
resp.setContentType("text/vnd.wap.wml");

// Create a PrintWriter to write the response
PrintWriter out = new PrintWriter(resp.getOutputStream());

// Login Card
out.println("<?xml version=\"1.0\"?>");
out.println("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"");
out.println(" \"http://www.wapforum.org/DTD/wml_1.1.xml\">");
out.println("<wml>");
out.println(" <card id=\"login\" title=\"Login\">");
out.println(" <p align=\"left\">");
out.println(" <fieldset>(1) Please enter <b>username</b>:</fieldset>");
out.println(" <input name=\"Name\" format=\"7A\" type=\"text\"/>");
out.println(" <fieldset>(2) Please enter <b>password</b>:</fieldset>");
out.println(" <input name=\"Pass\" format=\"5N\" type=\"password\"/>");

out.println("<do type=\"accept\" name=\"next\" label=\"Go\">");
out.println("<go href=\"#valid" method=\"post\">"); // Go to Valid Card
out.println("<postfield name=\"userName\" value=\"$(Name)\"/>");
out.println("<postfield name=\"userPass\" value=\"$(Pass)\"/>");
out.println("</go>");
out.println("</do>");

// Could these 2 lines be the source of the problem?
String Name = req.getParameter("userName");
String Pass = req.getParameter("userPass");

// Validate Card
out.println(" <card id=\"valid\" title=\"Validation\">");
out.println(" <p align=\"left\">");


if (Name.equals("USER") && Pass.equals("12345")) {
out.println("Welcome <b>" + Name + "</b>! Username and Password have been verified. Please proceed.");
out.println(" <do type=\"accept\" name=\"next\" label=\"Proceed\">");
out.println(" <go href=\"http://localhost:8080/jsdg-wap/LOF3\" method=\"post\">");
out.println(" </go>");
out.println(" </do>");
}

else {
out.println("Invalid Username and/or Password entered. Please try again.");
out.println(" <do type=\"options\" name=\"back\" label=\"Back\">");
out.println(" <go href=\"#login" method=\"post\">");
out.println(" </go>");
out.println(" </do>");
}

out.println(" </p>");
out.println(" </card>");
out.println("</wml>");
out.flush();


}


public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req, resp);
}

}

-------------------------------------------------------


Thanks a Lot!
Zen

Reply With Quote
  #2  
Old March 10th, 2004, 05:36 PM
ChiralSoftware ChiralSoftware is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Beverly Hills
Posts: 45 ChiralSoftware User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to ChiralSoftware
I see the problem

The variables are never getting to the servlet because they are never being sent to the servlet. Remember, a WML "page" is not a page at all. WML is totally different from HTML (and much better for mobile devices I might add). WML stacks consist of cards. Once the phone loads an entire stack (ie, .wml file) then it doesn't need to go back to the server ever to switch between cards within that stack (.wml file). So, when your card does a <go> to id #valid, it just goes to it in memory, without making any request to the server, even though you are using method=post. It would take me some time to read through the spec of wml and figure out if this is really the correct behavior, but in practice, I am not surprised that real devices would do it this way, and it may be the spec, also.

So the solution is to break these two cards into separate .wml files.

Let me know how it goes.

------------
Take the pain out of creating a WML server

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreWAP Programming > Pass WML variables to Servlet


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway