[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-08-14
4
Medium Priority
?
207 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
2 Comments
 
LVL 3

Accepted Solution

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

0
 
LVL 3

Assisted Solution

by:pat5star
pat5star earned 500 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

Independent Software Vendors: 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

Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

834 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