Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 5th, 2002, 03:57 PM
socrates73 socrates73 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 0 socrates73 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Variables

Hello, I am just curious if a variable is not defined in the JSP page, but is passed through the URL if can be accessed in the page? For exampe:

URL

<sample.jsp>
<HTML>
<%
if (variable == "test") {
out.println("Variable = test\n");
}
%>
</HTML>

Reply With Quote
  #2  
Old July 5th, 2002, 11:20 PM
jnicholas jnicholas is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 5 jnicholas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
A variable doesn't appear automatically like it does in php. You can grab a query string variable like this:

<% String myvariable = request.getParameter("variable"); %>

Also you can't test for string equality the way you did. if(variable == "test") would test if variable and "test" were the actual same object not just the same characters. you need if(variable.equals("test")) .

outprintln() also includes a line return already so you don't need the \n

Reply With Quote
  #3  
Old July 6th, 2002, 01:48 PM
socrates73 socrates73 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 0 socrates73 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by jnicholas
A variable doesn't appear automatically like it does in php. You can grab a query string variable like this:

<% String myvariable = request.getParameter("variable"); %>

Also you can't test for string equality the way you did. if(variable == "test") would test if variable and "test" were the actual same object not just the same characters. you need if(variable.equals("test")) .

outprintln() also includes a line return already so you don't need the \n

ok thanks for the help, i appreciate it... but i have another question, does jsp allow you to encrypt objects in the query string... for example in coldfusion i could encrypt the value of variable with something like this :
<CFSET variable2 = Encrypt(key, variable)>

this just adds a little more peace of mind when dealing with user information.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Variables

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap