Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!

Larry Lee

Greenhorn
+ Follow
since Jul 12, 2013
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 Larry Lee

Bear Bibeault wrote:It's always easy to think that something has happened. But the exception proves otherwise. Put the checking code into the servlet and see where things go from there.

But you haven't answered the question, what do you want to happen when a null value is detected?



i am thinking of checking whether the public key of the server is null.
If it is null, i will ask for a re transmission.
If it is still null, i will assign it a random value and also convey it to the client side.
7 years ago

Bear Bibeault wrote:Well, what are you going to do about it? Why did you remove the checking? It's an important part of the process.



i will code it out. It was a moment of folly
But i still don`t understand why it threw such an exception, my client passed the variables to the server correctly.
7 years ago

Bear Bibeault wrote:There's no such statement in your posted code.

Also, you need to do more than just print something out. What do you really want the servlet to do if the value is null? It's always a real possibility that your code must be able to handle.



My apologies, i deleted that section away previously.
I just factored it in for checking as i want to get the main functions out first
7 years ago
My client side code

7 years ago

Bear Bibeault wrote:

Larry Lee wrote:however i checked that the string that i`m initialising it with contains a value.


I see no evidence of code that does this checking.



i just did a normal if statement for it

if([string-name] != null]
System.out.println("i`m not a null string");

i also printed the values out to ensure that they have values in them
7 years ago

Paul Clapham wrote:Then your pk2 variable is null.

Here's where you assign a value to it:



but if there's no "publicK" parameter in the request then null is assigned to the variable. You'll want to put in some code which checks for that.

Also, there's no point in calling the toString() method of a String variable. Just use the variable itself.



the publicK is sent from my client application to the servlet. i shall update my first post with my client side code
7 years ago

Bear Bibeault wrote:SEVERE: Servlet.service() for servlet [DHServlet] in context with path [/MyServletProject] threw exception
java.lang.NullPointerException
at DHServlet.processRequest2(DHServlet.java:165)


Which line is 165?



this is the line
biPK = new BigInteger(pk2.toString());
7 years ago
Hi guys, i written a servlet function to incorporate a DH key exchange.
However i keep getting a null pointer exception on a BigInteger variable.
I know that you can`t initalize a BigInteger with a null variable , however i checked that the string that i`m initialising
it with contains a value.
As i am a novice in servlet writing, i`m rather confused what is going on with my code. Hope you guys can help me out here because i`m really stumped on this.

Thanks in advance

Below is my code snippet



and my log from the tomcat

7 years ago