Oprah Thaddeus

Ranch Hand
+ Follow
since Nov 08, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Oprah Thaddeus

Frits Walraven wrote:Hi Swagato,

Because you are submitting a parameter with the name "name" it will handle it as an empty String, and therefore outputing an empty String instead of your default value. If you remove <input type="text" name="name"> from your jsp it should work as you had expected.

Regards,
Frits



Thanks

Frits Walraven wrote:Hi Swagato,

Because you are submitting a parameter with the name "name" it will handle it as an empty String, and therefore outputing an empty String instead of your default value. If you remove <input type="text" name="name"> from your jsp it should work as you had expected.

Regards,
Frits



So, not providing any data in the form basically means an "empty string". Whereas no input type means null? AM i right?


Above is copied from bert's book.

Now let us imagine that value is null.
And the attribute "userLevel" does not exist.

What happens?

I know that if the value is null, then the var is removed from the scope. If the scope is default then it starts looking at page scope, then request, then session , then..

And if the var does not exist, then it is created in the scope specified and if no scope specified then on default page scope.

What if the value is null and the var does not exist in the particular scope?
I am just trying to print a default value when the user does not input any values in the form (of page index.jsp).


In the Bert's book of 2nd edition, it states that

This value is output if the value attribute evaluates to null. And, the above should render as




Here is the jsp page that does the c : out testing with default.


Here is the index.jsp page


I do not get the default value printed when there is no input in the form. I expected the default guest value should get printed!

Ulf Dittmer wrote:WEB-INF is not the place to put jar files; WEB-INF/lib is. Have you configured the web app for JSTL 1.2 as described on those pages?



Now working. I created a lib folder under WEB-INF. and placed the jar files there

Ulf Dittmer wrote:Have you installed the JSTL jar files where the web app can find them, and configured your web app correctly? http://faq.javaranch.com/java/ElOrJstlNotWorkingAsExpected and the pages it links to tell you everything you need to know about downloading and setting up JSTL in your web app.



I have right now copied both "jstl-impl-1.2.jar and jstl-api-1.2.jar" under ".....\MyProjects\JSTLTest\web\WEB-INF" . Still the same problem.

Please help.

I do not know how to install JSTL.

Just starting to learn JSTL

This is what I did

I copied "jstl.jar" from "C:\apache-tomcat-6.0.18\apache-tomcat-6.0.18\webapps\examples\WEB-INF\lib" and placed in under ".....\MyProjects\JSTLTest\web\WEB-INF"

Then created a file index.jsp


But it says that "The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application"

Christophe Verré wrote:request.getParameter("empID") == null || "".equals(request.getParameter("empID").trim())

If you'd use EL instead of scriptlets, you could use the empty operator instead, with JSTL's c:if tag.



Thanks...

I am just learning the JSTL :-)

Christophe Verré wrote:

I assumed that I would get null string. The assumption was wrong


I always forget about it too.

Secondly, I forgot about == and .equals


You'll never forget it again now



Thanks. But how do I check to make sure that the user has atleast inputed a value ? The value can be anything other than whitespace. How Do I do this?

request.getParameter("empID").equals (" ") only checks for one whitespace. I want to make sure that doesnt matter how many whitespaces the user puts, I still check to make sure there is something else other than whitespace?
Please fix your code using <code> </code> from above.. Thanks..

[ UD: Note that code tags use rectangle brackets, not angle brackets. ]
10 years ago
JSP
I think I am getting string with "" for not inputing any data in the form. Is that an empty string or string with no whitespace. I mean string with no contents and whitespace is empty right?

I assumed that I would get null string. The assumption was wrong

Secondly, I forgot about == and .equals

Christophe Verré wrote:

Is it going to be empty string or null string or " "?


Why don't you check it ?





Thank you for the hints. I spent a whole evening until midnight on this . grrr...

Yeep I have forgotten about Strings JAVA I think. How could I in such short time? blah

ANyway, I fixed it. thanks. I should have used the equals method as what I wanted is too check to make sure that two string vales are same not the two exact string objects..

Bear Bibeault wrote:If a bean is already bound in the specified scope with the same name, it will be attached. A new bean is created only if one does not already exist.



You mean the body of the useBean will be executed iff bean DOES NOT exist in the scope. Am I right?

Christophe Verré wrote:Did you try to check for an empty string ?

if (request.getParameter("empID") == "111")


You must have forgotten how to compare String variables (SCJP).



Is it going to be empty string or null string or " "?

Bear Bibeault wrote:Almost. It's not always true that a new bean will be created.



Now I am confused. Example please