Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Any one pls tell answer quickly....

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Any one pls tell answer quickly....

    Hi,

    When a direct visitor comes to our site, we are unable to maintain cookies and session. For example, when visitor comes to our site for the first time, we get a null pointer exception. This is not happening when there is a return visitor to our site. Any idea why this could be happening?

    Each page has a body tag. On loading the body tag, we don't get session values. We are getting only a null pointer exception (this is happening for a first time visitor only). When the same visitor comes back to our site, we are not getting a null pointer exception, and it seems to work fine.



    <%Pattern p = Pattern.compile( "([0-9]*)" );
    Matcher match=p.matcher(session.getAttribute("zip").toStri ng());
    if(match.matches()){%>
    <body bgcolor="#778899" onload="change(),zipValid('<%=session.getAttribute ("zip").toString() %>')">
    <%}else{ %>
    <body bgcolor="#778899" onload="change()">
    <%} %>

    <%
    String zipSes=session.getAttribute("zip").toString();
    String locationss=request.getParameter("id");
    if(locationss==null){

    locationss=zipSes;
    %>



    Basically, whenever a visitor comes back to our site, we are trying to pre-fill the zip code field with the zip code they last searched with. If they are searching during the same session, then we are trying to pre-fill the zip code with which they searched previously.
    Last edited by copeg; July 6th, 2012 at 09:09 AM.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,629
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Re: Any one pls tell answer quickly....

    Well a null pointer is what you would expect the first time, right? I mean, if no cookies exist for the user, the zip code will naturally be null.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Any one pls tell answer quickly....

    yes ..the first time User come to our site at the time throw the null pointer exception...if any other idea to set the cookies ..it is possible

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,629
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Re: Any one pls tell answer quickly....

    Well the problem is that there are no cookies. The only solution here (as far as I can think of) is to take into account the case when no cookies exist and give zip code some sort of value to work with.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  5. #5
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Any one pls tell answer quickly....

    Mysql usage is still high on our server.........So what are the steps to solve this problem?pls anyone reply quick..

Similar Threads

  1. Pls Answer...
    By sachin.garde in forum Exceptions
    Replies: 4
    Last Post: October 31st, 2011, 02:38 AM
  2. What's ur answer?
    By Tanmaysinha in forum The Cafe
    Replies: 6
    Last Post: October 12th, 2011, 06:26 AM
  3. need answer for these
    By satishbs in forum Java Theory & Questions
    Replies: 2
    Last Post: April 15th, 2011, 01:46 AM
  4. need help quickly plz!!!
    By computerfreak.7777 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 11th, 2010, 01:32 AM