Java jsp调用中的非静态变量和静态函数

Java jsp调用中的非静态变量和静态函数,java,jsp,rest,static,Java,Jsp,Rest,Static,我试图从JSP页面调用用java编写的restful web服务 我有一个简单的RESTWeb服务,它返回JSP页面发送的相同post数据。 为了发送post数据,我在jsp中声明了字符串,并希望在函数(API)中访问该字符串以将post数据发送到web服务 我的JSP页面是 <%! static public String input = "hello";%> <% Client client = Client.create(); WebResource service =

我试图从JSP页面调用用java编写的restful web服务

我有一个简单的RESTWeb服务,它返回JSP页面发送的相同post数据。 为了发送post数据,我在jsp中声明了字符串,并希望在函数(API)中访问该字符串以将post数据发送到web服务

我的JSP页面是

<%! static public String input = "hello";%>
<%
Client client = Client.create();
WebResource service = client.resource("http://localhost:8080/ITHelpdesk/webresources/hello.viewinfo");

ClientResponse cliresponse = WebResource.type("text/html").post(ClientResponse.class,input);

%>
我应该如何处理非静态函数中的非静态变量。

您已经在
服务
变量中存储了
WebResource
引用。然后你就忽略了它。我猜你只是想:

ClientResponse cliresponse = service.type("text/html")
                                    .post(ClientResponse.class,input);

为什么在JSP中使用
static
变量?事实上,为什么在JSP中使用scriplets?
ClientResponse cliresponse = service.type("text/html")
                                    .post(ClientResponse.class,input);