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!
  #16  
Old February 25th, 2008, 04:47 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 909 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: 41984 Folding Title: Beginner FolderFolding Points: 41984 Folding Title: Beginner FolderFolding Points: 41984 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 4 h 48 m 57 sec
Reputation Power: 420
Quote:
Originally Posted by shruthi_cd
String username2=req.getParameter("name").trim();
String password2=req.getParameter("pswd").trim();
String confirmpassword2=req.getParameter("confirmpswd").trim();


req.getParameter() can return null if any of the parameters do not exist. Check if the names used are correct.

Also, I would recommend writing the code a little more robust. Example:
java Code:
Original - java Code
  1.  
  2. String username           = "";
  3. if(req.getParameter("name") != null)
  4.     username = req.getParameter("name").trim();
  5.  
  6. // Same for the other fields.
  7.  


A proper null reference checking will ensure that you don't get NullPointerException.

Quote:
Originally Posted by shruthi_cd

Can you give your private mail id if possible??


Sorry, no.
__________________

Reply With Quote
  #17  
Old February 25th, 2008, 04:58 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
req.getParameter() can return null if any of the parameters do not exist. Check if the names used are correct.

Also, I would recommend writing the code a little more robust. Example:
java Code:
Original - java Code
  1.  
  2. String username           = "";
  3. if(req.getParameter("name") != null)
  4.     username = req.getParameter("name").trim();
  5.  
  6. // Same for the other fields.
  7.  


A proper null reference checking will ensure that you don't get NullPointerException.



Sorry, no.



I am not getting nullpointerexception for the program but it says cannot load servlet. Is the insert into statements correct?? I am sorry for asking your mail id. I thought i can clarify my doubts. anyway sorry.

Reply With Quote
  #18  
Old February 25th, 2008, 05:38 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 909 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: 41984 Folding Title: Beginner FolderFolding Points: 41984 Folding Title: Beginner FolderFolding Points: 41984 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 4 h 48 m 57 sec
Reputation Power: 420
Could you print the stack trace from your program and post it here?

Reply With Quote
  #19  
Old February 25th, 2008, 11:01 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
Could you print the stack trace from your program and post it here?



This is the stack trace i got in my program


Nov 26, 2007 10:32:31 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet RegisterServlet threw exception
java.lang.NullPointerException
at RegisterServlet.doGet(RegisterServlet.java:30)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProt ocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

Reply With Quote
  #20  
Old February 26th, 2008, 08:00 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 909 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: 41984 Folding Title: Beginner FolderFolding Points: 41984 Folding Title: Beginner FolderFolding Points: 41984 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 4 h 48 m 57 sec
Reputation Power: 420
Quote:
Originally Posted by shruthi_cd
SEVERE: Servlet.service() for servlet RegisterServlet threw exception
java.lang.NullPointerException
at RegisterServlet.doGet(RegisterServlet.java:30)


If the actual line numbers in your code are the same as what you posted, you are getting a NullPointerException around where I thought it would be -
java Code:
Original - java Code
  1. String username2=req.getParameter("name").trim();


I recommend that you modify your code to check for the null reference, as suggested earlier.

Reply With Quote
  #21  
Old February 26th, 2008, 11:08 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
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 RegisterServlet extends HttpServlet
{

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

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


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

out.println("<?xml version=\"1.0\"?>");
out.println("<!DOCTYPE wml PUBLIC " + "\"-//WAPFORUM//DTD WML 1.1//EN\" "
+ "\"http://www.wapforum.org/DTD/wml_1.1.xml\">");

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


try {


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


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

String str = "insert into login values(?,?)";
ps = con.prepareStatement(str);

String username3=req.getParameter("name");
String password3=req.getParameter("pswd");
String confirmpassword3=req.getParameter("confirmpswd");

ps.setString(1, username3);
ps.setString(2, password3) ;

ps.executeUpdate();

res.sendRedirect("registrationsuccess.wml");
// show that the new account has been created
out.println(" Hello : ");
out.println(" '"+username3+"'");
ps.close();

}

catch (IOException e) {

// you handle the exception here
e.printStackTrace();

}

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) { }
}


}
}


Now i am getting another strange problem, the null values are getting inserted into database. I am passing parameters correctly know? Can you please modify my code so that i can correctly insert the values into database.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreWAP Programming > Wml With Servlets .. Does It Work?


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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