Reputation: 21
I have a java code which returns specific columns from a log file. I am asked to display the returned values using jsp. Since I am new to web programming I am not sure how to go about. If someone could guide me in a step by step manner.
The values returned in the java code are in this format:
Edmess_p_b_actual_stdunit SO
Edmess_p_c_dataload HU
Upvotes: 1
Views: 4332
Reputation:
I am not much clear about the quesion. But what I could understood, in Java there is a method which returns a value. And in JSP you can call the method and print the return value. If this is what your question, then below are the steps...
1) Import the package in jsp using
<%@ page import="<your package and class" %>
2) If the method is static, you can just use the expression such as:
or scriptlet such as:
<%
out.println(MyClass.myMethod());
%>
3)If the method is instance method, you need to instantiate and call the method as:
<%
MyClass obj = new Myclass();
out.println(obj.myMethod());
%>
However it is just only for beginners to understand the JSP, but don't use in your development code. Always use a business layer who calls those methods and store in a request/session scope. Then print the value in jsp
Upvotes: 1
Reputation: 7799
You should make your Java code a servlet or be called by a servlet. It should store the information into one or more JavaBeans. Then from JSP you can use library tags and JSP expressions to retrieve and display the information.
I am assuming you are not using any framework, just plain servlets. Find out if this is the case and, if not, what's the framework you are supposed to use.
Upvotes: 0