Solved

Check for a variable if it's available on the server

Posted on 2004-08-14
4
204 Views
Last Modified: 2012-05-05
I want the statement that check if a specific variable is available on the server variables or not.

I need that in order to check for the availability of a specific variable. So that if the any one reached the page directly i can display my own message instead of null pointer exception raised by the compiler
0
Comment
Question by:The_Gutsy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Accepted Solution

by:
sbockelman earned 125 total points
ID: 11801237
String sExpectedVariableValue = request.getParameter( "theExpectedVariables" );
if( null == sExpectedVariableValue ) {
    // kick them out!
}

0
 
LVL 3

Assisted Solution

by:pat5star
pat5star earned 125 total points
ID: 11818378
You should store a specific word in the users session from your main entry page, like a login page.

HttpSession session = request.getSession();
session.setAttribute("secretWord", "secret");

Then on every page that you only want 'logged in' users you check for the secretWord like this:

if (null != session.getAttribute("secretWord") && "secret".equals((String)session.getAttribute("secretWord"))) {
  // They are logged in
} else {
  // They are not logged in, send error message...
}

What this does is check that the session attribute "secretWord" is not null and that it does equal the value "secret". If not, you know they came to the page directly and can then handle it whatever way you want.

Hope that helps,

-Pat
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Make the most of your online learning experience.
Learn why we support net neutrality and why the topic is important to all internet users.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

696 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