No, the first solution should't work:
% break; %
% case 2: %
Will be tranformed to something like:
break;
out.print(\n);
case 2:
That doesn't look like valid java syntax to me.
These will work:
% break;
case 2:
%
% break;
%% case 2: %
However, I prefer the JSTL
Ralph Einfeldt wrote, On 2/24/2004 12:41 AM:
No, the first solution should't work:
% break; %
% case 2: %
You're right, missed that one. Anyway, the original poster should get
the idea. ;-)
However, I prefer the JSTL solution.
(But can't use it, a we still use JSP 1.0)
JSP 1.0???
Even TC
We are still using gnujsp.
To switch to tomcat isn't that easy. The servlets
and the jsp work, but we would have to change our
complete automated deployment process.
(And there wasn't enough reason to do so by now)
-Original Message-
From: David Rees [mailto:[EMAIL PROTECTED]
Sent:
Ah neat. I was wondering how to use the basic idea. I showed it as out.println but I
knew there had to be a better way. Thanks much Antonio.
--
George Hester
__
Antonio Fiol Bonnín [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
George Hester wrote:
In Tomacat this works fine:
-- switch.jsp --
!-- BEGIN --
!doctype html public -//W3C//DTD HTML 4.0 Final//EN
%
int day = 3;
%
html
head
titleTest Switch/title
/head
body
% switch (day) {
case 1:
out.println(Sunday);
break;
case 2:
out.println(Monday);
break;
default:
out.println(No
George,
OK, I'll bite. Why?
Not sure why you want to try this but from what I understand, no it won't
work. The clue is that the jsp page is converted to a servlet and any code
between the % % must stand on it own as valid code. When you split the
code you have created two segments that if
Well according to Core JSP by Damon Hougland and Aaron Tavistock © 2001 Prentice Hall
(pgs 26-28) it should work.
For example this works:
% if (day == 1 | day == 7){ %
font color=red size=+1
It's the weekend!/font
% } else { %
font color=red size=+1
Still in the work week./font
Because the switch statement has different syntax.
% switch (day) { %
% case 1: // and so on...
%
Could be translated to:
switch (day) {
out.print(\n );
case 1: // and so on...
Which is clearly illegal syntax. There is no equivalent illegal form of
any other block construct, which
Thanks. I wish Damon Hougland and Aaron Tavistock knew that before they published
their Sun sanctioned book. It would have saved me a lot of frustration. I really
expected Sun's CORE books to be better then Wrox.
Their example was this which failed:
% switch (day) { %
% case 1: %
font
Okay, so I learned something. I was right but also wrong. As I said my
understanding which now is New and Improved. Use ifs not switches on jsp.
Got to write that down somewhere .
Sorry George.
Doug
- Original Message -
From: George Hester [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
George Hester wrote:
Thanks. I wish Damon Hougland and Aaron Tavistock knew that before they published their Sun sanctioned book. It would have saved me a lot of frustration. I really expected Sun's CORE books to be better then Wrox.
Their example was this which failed:
% switch (day) { %
%
Thanks. I wish Damon Hougland and Aaron Tavistock knew that before they
published their Sun sanctioned book. It would have saved me a lot of
frustration. I really expected Sun's CORE books to be better then Wrox.
Their example was this which failed:
% switch (day) { %
% case 1: %
font
12 matches
Mail list logo