Solved

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

Posted on 2004-08-14
4
201 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
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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to view directory list in apache/tomcat 9 115
IE doesn't Invoke servlet in iframe 1 111
How can I   ajax html table  rows? 20 76
jsp login check 12 31
This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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