."/> .">

Home >Java >javaTutorial >How to reference java functions in jsp

How to reference java functions in jsp

(*-*)浩
(*-*)浩Original
2019-05-18 16:38:474291browse

First create a new project and add a package under the src folder: such as: cn.tianaoweb.com;

How to reference java functions in jsp

## Then add a package to the package Class: For example,

package com;
public class test {
    public String sd(){
        return "sd";
    }
}

is introduced at the beginning of the default homepage index.jsp (of course you can also create a new jsp file yourself).

<%@ page import="cn.tianaoweb.com.*"%>

Add the corresponding java code piece in :

<%
  String str;
  test te=new test();%> 
<%=te.sd()%>
In this way, the Java function is successfully referenced. Go to the JSP page.

The above is the detailed content of How to reference java functions in jsp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn