0

I am working on a project that runs a java back-end and has a web page UI.Basically, the java system runs in on the server and keeps a log of rules that are created in the web page. What I need it to do is take inputs from the text fields on the web page and call a function to pass them to the java object to create a new rule. I also need to be able to call a function to return an array of the rule objects I have created so I can build a table of them on the web page.

I have the UI built as a JSP page and the back-end java classes and functions are all built but I am lost as to how to connect the two.

This is my first attempt at creating a system like this and I have never written anything with Java EE or JSP before.

What I was thinking I could do would be to call a java function when I click the "submit" button to add a new rule and pass the field values to it. I had the same feeling for when I click a button to display the current rules, calling a java function to get the array of objects back and build it into a table.

Does anyone have any insight onto this?

Thanks!

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
  • 1
    Please look in to Java servlets as a starting point. There are a zillion different ways to go about this, from very simple (servlets) to rather complex (particularly when things break). – Dave Newton Oct 26 '12 at 14:36

2 Answers2

0

As Dave Newton said, there are various ways to deal with that. The easiest one is to use an Web Framework. You can Google Java Web Framework or read this post.

If you are looking for something to work with JSP, lightweight and very easy to use, I would go for Stripes.

Community
  • 1
  • 1
Trein
  • 3,658
  • 27
  • 36
0

I hope you want to know if you can create objects of the backend Java classes in JSP and call functions of these objects. For that you can use:

scriplet tag <% any java code in between%>

<% A a=new A();
a.funtion_of_class_A();%>

To display the content you can use expression tag.

<%=a.someotherfuntion()%>

You can use directives to import and initialize and define the variables

<%@ page import="com.a" %>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Vikky
  • 1,123
  • 14
  • 16
  • 1
    It is not a good practice to put [Java code in JSP pages](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files). – GriffeyDog Oct 26 '12 at 16:06
  • Exactly, +1 for GriffeyDog's comment. That is why web frameworks like Spring MVC, JSF, Struts2, etc are so popular. They help you to decouple your presentation logic from your business logic. – Trein Oct 27 '12 at 14:51