Quick ASP to JSP Code Conversion questions...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeremy_Krall
Posted On:   Thursday, March 7, 2002 10:56 AM

I am not familiar at all with JSP and just trying to understand some basic formatting in a simple JSP page. Here is some ASP code, could someone provide equivalent code in a JSP environment? It would be of great help. Right now I am concentrating on a beanless environment given the simplicity of what I am doing. ASP Code: Standard IF->Then Statment: If Request("bgcolor") <> "" Then bgcolor = Request("bgcolor") Else bgcolor = "C6C3C6" End If Cookie Setting: Response.Cookies("name") = "bob" Response.Cookie   More>>

I am not familiar at all with JSP and just trying to understand some basic formatting in a simple JSP page.


Here is some ASP code, could someone provide equivalent code in a JSP environment? It would be of great help. Right now I am concentrating on a beanless environment given the simplicity of what I am doing.


ASP Code:


Standard IF->Then Statment:


If Request("bgcolor") <> "" Then

bgcolor = Request("bgcolor")

Else

bgcolor = "C6C3C6"

End If


Cookie Setting:


Response.Cookies("name") = "bob"

Response.Cookies("name").Expires = Date + 365


Select Statement:


Select Case LCase(getname)

Case "bob"

title= "CEO"

Case "jim"

title= "COO"

Case Else

title= "Employee"

End Select


If anyone could respond with some sample code I would appreciate it. It offers me a great starting point!


Thanks in advance.

   <<Less

Re: Quick ASP to JSP Code Conversion questions...

Posted By:   Anonymous  
Posted On:   Friday, March 8, 2002 02:15 AM

An ASP page uses VisualbasicScript, while a JSP page uses Java as the programming language.

Even if Java is a real language, there are very few difference on the syntax of the IF (Java Language Specifications 14.9) or SWITCH/CASE (Java Language Specifications 14.10) statements. These are some examples:

if (expression) [{]
Statement
[}] else [{]
Statement
[}]

if (expression) {
Statement
Statement
...
} else {
Statement
Statement
...
}


switch (expression) {
case ConstantsExpression:
Statement
...
[ break ]
default:
Statement
...
}

regarding the use of objects like Cookie or Request, you really should read the documentation of those objects to see what you can do.


Regards

About | Sitemap | Contact