Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Is there a method like (!isDefined()) in JSP

Thread view: 
anubhakhurana@gmail.com - 12 Oct 2006 02:19 GMT
Hello! I have 2 files A.jsp and B.jsp. A.jsp is including B.jsp. There
is a variable defined in A.jsp which is being used in B.jsp. Now B.jsp
should check that if the variable is not defined than it should define
and put a default value in the variable in B.jsp. So in JSP do we have
something like !isdefined(var). or is there any other way I can solve
this problem.

Thanks in Advance
Anubha
Mark Space - 12 Oct 2006 06:50 GMT
> Hello! I have 2 files A.jsp and B.jsp. A.jsp is including B.jsp. There
> is a variable defined in A.jsp which is being used in B.jsp. Now B.jsp
> should check that if the variable is not defined than it should define
> and put a default value in the variable in B.jsp. So in JSP do we have
> something like !isdefined(var). or is there any other way I can solve
> this problem.

I'm pretty sure what your asking is not directly possible.  Java, unlike
scripting languages like Perl, JavaScript and others, does not permit
you to access undefined variables at all.  It's an error at compile time.

If you are having problems like this, you probably want to pass a
(defined) object like a collection, then you can check the contents of
the collection for what pairs of data are defined.  This can get
complicated if you over use it, so be careful.

Also, there's a process called Reflection that does allow you to
discover the type, methods, and other information about objects, without
knowing anything about them to begin with.  This might be useful,
depending on what you are trying to do.

But if "var" isn't defined, then your program won't compile, and you
can't test for it, because it would have to be defined first.
anubhakhurana@gmail.com - 12 Oct 2006 07:53 GMT
Thanks a lot for your reply. It was really helpful.

> > Hello! I have 2 files A.jsp and B.jsp. A.jsp is including B.jsp. There
> > is a variable defined in A.jsp which is being used in B.jsp. Now B.jsp
[quoted text clipped - 19 lines]
> But if "var" isn't defined, then your program won't compile, and you
> can't test for it, because it would have to be defined first.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.