Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Null  pointer on no name value pair

Posted on 2004-11-24
2
Medium Priority
?
194 Views
Last Modified: 2011-09-20
If I pass in a name value pair for "platform" my code worksbut if I don't I get a null pointer exception. Why am I getting that?I
www.mydomain.com/test.jsp?platform=xbl  (works)
www.mydomain.com/test.jsp  (does NOT work)
---------------------------
<%
    HttpSession sess = request.getSession(true);
    String nfsu2SelectedPlatform = (String)sess.getValue("nfsu2SelectedPlatform");
    String platform = request.getParameter("platform");
          
     if (nfsu2SelectedPlatform.equals("null")) {
        sess.setAttribute("nfsu2SelectedPlatform", "ps2");
          platform ="ps2";
       } else {
              if ((!(nfsu2SelectedPlatform.equals(platform)))&&(!(platform.equals("null")))){
         sess.setAttribute("nfsu2SelectedPlatform", platform);
         }
      }
%>
0
Comment
Question by:894359
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 12672513
>           if ((!(nfsu2SelectedPlatform.equals(platform)))&&(!(platform.equals("null")))){

should be:

          if (platform!=null && !nfsu2SelectedPlatform.equals(platform)){
0
 
LVL 92

Expert Comment

by:objects
ID: 12672514
>     if (nfsu2SelectedPlatform.equals("null")) {

similiarly for this:

    if (nfsu2SelectedPlatform!=null) {
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The number of companies understanding the potential of IoT on B2B market is growing with each day. And yet only a small share of IoT developers have managed to equalize incomes and stay competitive in the international market.
If you need to complete a Physical to Virtual (P2V), Virtual to Virtual (V2V) conversion to a VMware product (VMware Workstation, Player or VMware vSphere (ESXi) ) for FREE, then there is some good news...
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question