Aidanc Aidanc - 11 days ago 5
Java Question

Jersey: Passing data to a .jsp page

I'm new to Jersey and Web app development. I've attempted to Google my problem but can't seem to find the correct answer on either Jersey's documentation or the Internet. I've got a complex data type called

User
. This data type contains various Strings and URI's. I'm attempting to pass a variable of this type from a java file to the jsp using the following code...

.java code

return new Viewable("/page.jsp", User);


.jsp code

<%@System.out.println(request);%>


I've tried various variations on the .jsp code that I found on mailing lists but they all seem to return the same error which is...

org.apache.jasper.JasperException: /page.jsp (line: 3, column: 7) Invalid directive
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:89)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:498)
org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1777)
org.apache.jasper.compiler.Parser.parse(Parser.java:135)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:193)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


Where am I going wrong?

Answer

<%@ ... %> indicates a directive in JSP. For a code snippet (scriptlet), use <% ... %>.