Declaring functions in JSP?
You need to enclose that in <%! %> as follows:
<%!
public String getQuarter(int i){
String quarter;
switch(i){
case 1: quarter = "Winter";
break;
case 2: quarter = "Spring";
break;
case 3: quarter = "Summer I";
break;
case 4: quarter = "Summer II";
break;
case 5: quarter = "Fall";
break;
default: quarter = "ERROR";
}
return quarter;
}
%>
You can then invoke the function within scriptlets or expressions:
<%
out.print(getQuarter(4));
%>
or
<%= getQuarter (17) %>
相關推薦
Declaring functions in JSP?
You need to enclose that in <%! %> as follows: <%! public String getQuarter(int i){ String quarter; switch(i){ case 1: quarter = "W
Const member functions in C++
pear treat not rul automatic man sel cannot example Recently, I‘ve started to review and learn C++ techniques. During the learning proces
[TypeScript] Define Custom Type Guard Functions in TypeScript
nal ria console tro res one inf arr asp One aspect of control flow based type analysis is that the TypeScript compiler narrows the type o
除錯經驗——如何檢視Oracle自定義函式 (How to view definition of user defined functions in Oracle)
問題描述: 現有的Query中似乎使用了一個自定義函式String_to_list,為了排查問題,需要檢視這個函式的定義。 方法: --新建的function,並未儲存在All_ojbects表中,而是儲存在user_objects表中 SELECT * FRO
[Bash] Understand and Use Functions in Bash
n this lesson, we'll go over how bash functions work. Bash functions work like mini bash scripts--you can pass parameters and invoke them just like
Table-valued functions and Scalar-valued functions in SQL Server
As the name suggests: table-valued returns table, however Scalar-valued returns a single value, such as a string, integer, or bit value. 1、table-valued fu
How to get browser information in JSP?
The following jsp will output your ip address and user-agent: Your user-agent is: <%=request.getHeader("user-agent")%><br/> Your IP address i
how to use “request” object within a function in jsp
request is accessible inside the scriptlet expressions, because it’s an argument of the method in which these expressions are evaluated (_jspService). But
Listeners with several functions in Kotlin. How to make them shine?
One question I get often is how to simplify the interaction with listeners that have several functions on Kotlin. For listeners (or any interfaces) w
First Class Functions in Golang
What are first class functions? A language which supports first class functions allows functions to be assigned to variables, passed as
Faulty Reward Functions in the Wild
Reinforcement learning algorithms can break in surprising, counterintuitive ways. In this post we'll explore one failure mode, which is where you mi
Useful functions in PHP
從手冊上整理了一些有用且比較常用的php函式, 便於以後查閱. 1. htmlspecialchars Convert special characters to HTML entities (PHP 4, PHP 5) string htmlspecialchar
Ninja Functions in Kotlin. Understanding the power of generics (KAD 12)
The combined use of several Kotlin features mixed with the use of generics allow to create functions that will greatly simplify your code, while main
Extension functions in Kotlin: Extend the Android Framework (KAD 08)
Extension functions are a really cool feature that Kotlin provides, and that you’ll find yourself using a lot when writing Android Apps. We have to a
Arrow Functions in Class Properties Might Not Be As Great As We Think
MockabilityIf you want to mock or spy on a class method, the easiest and proper way to do so is with the prototype as all changes to the Object prototype o
"First Class Functions in Go"
30 June 2011 Programmers new to Go are often surprised by its support for function types, functions as value
hive中使用case、if:一個region統計業務(hive條件函式case、if、COALESCE語法介紹:CONDITIONAL FUNCTIONS IN HIVE)
CREATE TABLE test_lmj_mdm_tmp AS SELECT guid, CONCAT('adn_',adn_id) AS adn, CONCAT('time_',substr(createtime,12,2)) AS hour, CONCAT('os_',os_id) AS os, cas
init functions in Go
init functions in GoIdentifier main is ubiquitous. Every Go program starts in a package main by calling identically named function. When this function retu
Lua 調用的 C 函數保存 state 的兩種方式: Storing State in C Functions 筆記
.com 包裝 ram targe cti gist 方式 機制 key http://yanbin.is-programmer.com/posts/94214.html Registery的Key 1. 整數Key用於Lua的引用機制,所以不要使用整數作為Key
[Javascript] Compose multiple functions for new behavior in JavaScript
multi new cal you ucc bsp reduce start aries In this lesson you will create a utility function that allows you to quickly compose behavio