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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 20th, 2008, 11:28 PM
shruthi_cd shruthi_cd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 21 shruthi_cd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 21 sec
Reputation Power: 0
Question Wml With Servlets .. Does It Work?

Hi, i am doing my project in wap technology. I am struck up in initial stage. I am trying to get username and password from wml page and directing it to servlet. But my browser says

" Cannot load http://localhost:8080/LoginServlet(Http 404 Error)"

Here is my code:

Login.wml

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "(URL address ">

<wml>
<card id="card1" title=" Semester Grade Enquiry System Login Form">
<p>
<big></big>Semester Grade Enquiry System Login Form<br/>
Notice: Fields with * are required.<br/><br/>

<b>$(errorMsg)</b><br/>

* User name:<br/>
<input name="username"/><br/>
* Password (min. 5 characters):<br/>
<input type="password" name="password"/><br/>

<a href="validateloginform.wmls#validate()">Submit Form Data</a>
</p>
</card>
</wml>

validateloginform.wmls

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "url address">

<wml>
<card id="card1" title="Success">
<do type="accept" label="enter">
<go href="/LoginServlet.java"/>
</do>
</card>
</wml>

LoginServlet.java

import java.io.*;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


import javax.servlet.*;
import javax.servlet.http.*;

public class LoginServlet extends HttpServlet
{

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

{
Connection con = null;
Statement stmt = null;
ResultSet rs = null;

res.setContentType("text/vnd.wap.wml");
PrintWriter out = res.getWriter();



String username2=req.getParameter("username");
String password2=req.getParameter("password");


out.println("<?xml version=\"1.0\"?>");
out.println("<!DOCTYPE wml PUBLIC " + "\"-//WAPFORUM//DTD WML 1.1//EN\" "
+ "\"(URL address )\">");

out.println("<wml>");
out.println("<card id=\"new\" title=\"login\">");
out.println(" <p> Login </p>");



try {


Class.forName("oracle.jdbc.driver.OracleDriver");


con = DriverManager.getConnection("jdbcracle:thin:@rccadv33:1521rcl", "scott", "tiger");


stmt = con.createStatement();



rs = stmt.executeQuery("select * from login");

while(rs.next())
{

if (username2.equals(rs.getString("username")) && password2.equals(rs.getString("password")))


{

out.println("<p>Login Successful<p>");
res.sendRedirect("success.wml");


}
else
{
out.println("<p>Please check the entries!<p>");
}
}
}
catch(ClassNotFoundException e)
{
out.println("Couldn't load database driver: " + e.getMessage());
out.println("hi");
}
catch(SQLException e)
{
out.println("SQLException caught is: " + e.getMessage());
out.println("<p>hi</p>");
out.println("</card>");
out.println("</wml>");

}
finally {

try {
if (con != null) con.close();
}
catch (SQLException ignored) { }
}


}
}


Can anyone help me in solving this issue.
Thanks in advance.

Reply With Quote
  #2  
Old February 21st, 2008, 06:30 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 7 h 50 m 59 sec
Reputation Power: 433
Quote:
Originally Posted by shruthi_cd
But my browser says

" Cannot load http://localhost:8080/LoginServlet(Http 404 Error)"



I would guess it indicates a problem with the servlet mapping specified.

Quote:
<go href="/LoginServlet.java"/>


I seriously doubt that you should be using the .java there, unless you have actually specified the mapping URL in that manner (in your web.xml).

Quote:
Can anyone help me in solving this issue.
Thanks in advance.


Post your web.xml which indicates the servlet mapping.

Also, use the code tag to preserve code formatting.
__________________

Reply With Quote
  #3  
Old February 21st, 2008, 11:18 PM
shruthi_cd shruthi_cd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 21 shruthi_cd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 21 sec
Reputation Power: 0
Quote:
Originally Posted by Annie79
I would guess it indicates a problem with the servlet mapping specified.



I seriously doubt that you should be using the .java there, unless you have actually specified the mapping URL in that manner (in your web.xml).



Post your web.xml which indicates the servlet mapping.

Also, use the code tag to preserve code formatting.







I have removed that .java extension . Is there any wml editors and editors to write my java code?

Reply With Quote
  #4  
Old February 22nd, 2008, 12:37 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 7 h 50 m 59 sec
Reputation Power: 433
Quote:
Originally Posted by shruthi_cd
I have removed that .java extension . Is there any wml editors and editors to write my java code?
Did it solve your problem?

If you are looking for editors (or IDE in specific), I personally prefer Eclipse. It has a WML editor in Web Tools plugin.

Reply With Quote
  #5  
Old February 22nd, 2008, 01:15 AM
shruthi_cd shruthi_cd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 21 shruthi_cd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 21 sec
Reputation Power: 0
Quote:
Originally Posted by Annie79
Did it solve your problem?

If you are looking for editors (or IDE in specific), I personally prefer Eclipse. It has a WML editor in Web Tools plugin.




Yes , after removing it, it is working. Thank you so much annie. one more issue, its working in nokia simulator but not in openwave. If i download eclipse, should i configure any settings for that??

Reply With Quote
  #6  
Old February 22nd, 2008, 01:58 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 7 h 50 m 59 sec
Reputation Power: 433
Quote:
Originally Posted by shruthi_cd
one more issue, its working in nokia simulator but not in openwave. If i download eclipse, should i configure any settings for that??


I'm not very conversant with WML myself. You might want to search for some documentation.
http://developer.openwave.com/dvl/support/documentation/technical_notes/sampleservlet.htm

Reply With Quote
  #7  
Old February 22nd, 2008, 02:21 AM
shruthi_cd shruthi_cd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 21 shruthi_cd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 21 sec
Reputation Power: 0
Quote:
Originally Posted by Annie79
I'm not very conversant with WML myself. You might want to search for some documentation.
(url)



Have you done any projects on wap/wml?

Reply With Quote
  #8  
Old February 22nd, 2008, 02:26 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 7 h 50 m 59 sec
Reputation Power: 433
Quote:
Originally Posted by shruthi_cd
Have you done any projects on wap/wml?
No, I only studied it out of interest some time ago.

Reply With Quote
  #9  
Old February 22nd, 2008, 03:18 AM
shruthi_cd shruthi_cd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 21 shruthi_cd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 21 sec
Reputation Power: 0
Quote:
Originally Posted by Annie79
No, I only studied it out of interest some time ago.



Hi I downloaded eclipse IDE . I am using Apache Tomcat Server. How to connect this server with my IDE?

Reply With Quote
  #10  
Old February 22nd, 2008, 03:33 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 7 h 50 m 59 sec
Reputation Power: 433
Quote:
Originally Posted by shruthi_cd
Hi I downloaded eclipse IDE . I am using Apache Tomcat Server. How to connect this server with my IDE?
http://www.eclipse.org/webtools/jst/components/ws/1.0/tutorials/InstallTomcat/InstallTomcat.html

Reply With Quote
  #11  
Old February 22nd, 2008, 04:04 AM
shruthi_cd shruthi_cd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 21 shruthi_cd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 21 sec
Reputation Power: 0
Quote:
Originally Posted by Annie79
http://www.eclipse.org/webtools/jst/components/ws/1.0/tutorials/InstallTomcat/InstallTomcat.html


Thank you so much annie.. I configured it.

Reply With Quote
  #12  
Old February 24th, 2008, 11:10 PM
shruthi_cd shruthi_cd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 21 shruthi_cd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 21 sec
Reputation Power: 0
Quote:
Originally Posted by shruthi_cd
Thank you so much annie.. I configured it.




For the above mentioned code, sometimes i get java.lang.NullPointerException at LoginServlet.doGet????
Why this error occurs??

Reply With Quote
  #13  
Old February 25th, 2008, 03:37 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner FolderFolding Points: 47997 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 7 h 50 m 59 sec
Reputation Power: 433
Quote:
Originally Posted by shruthi_cd
For the above mentioned code, sometimes i get java.lang.NullPointerException at LoginServlet.doGet????
Why this error occurs??
A NullPointerException can occur because some object is null and a method is being invoked. Your exception stack trace should indicate the line number at which the exception is generated.

Reply With Quote