?
Solved

Need Suggestion on re-writting code from JAVA to JSP

Posted on 2004-03-30
7
Medium Priority
?
491 Views
Last Modified: 2008-02-01
Hello,

I would like to know what is the processs and what should I keep in mind when
converting some working code that is wrtten is Java using JTree and uses Swing to create a Tree - view ...
and convert it into JSP so it can be viewed on the web - browswer ?


What would be your suggestion on tips to keep in find
and how easy / hard is it to implement - convert Java to JSP
and how long would it take to implement it?


Awaiting a response ..
Thanks

0
Comment
Question by:sdesar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Assisted Solution

by:gagaliya
gagaliya earned 100 total points
ID: 10717268
Converting java to jsp is not hard. jsp IS java wrapped in html. In general,  just put your java code in <% %> tag on a jsp  and you basically converted a java class into jsp

BUT there is no easy way to convert a swing based custom ui into jsp. This is due to the limitation of html.   You can:

1) Use an applet instead of jsp, then it is very easy to convert. Basically you just wrap the ui you have now in an applet so it shows up on browser. The downside is some users may not be able to view applets due to security, browser, or plugins they (don't) have.

2) Use javascript to recreate the tree view. There are many tree based templates on the web, do a search on google

gaga
0
 

Author Comment

by:sdesar
ID: 10717843
Thanks for answering the question!

I placed the Java code within <% %>

This is the code scriptlet -
<%
public NodeProducer createProducer(Node[] anode) {
..... bla bla..


}

%>

this is the error message .. what am I doing wrong ?

 illegal start of expression
public NodeProducer createProducer(Node[] anode) {
^
0
 
LVL 13

Accepted Solution

by:
copyPasteGhost earned 100 total points
ID: 10720399
If you want to include classes in jsp you have to make a JavaBean

that's just a regular java class file that you call from within your jsp page.
for example.
let's say you have the class MyClass in pacakge mypackage

package mypackage;

public class MyClass {

  public MyClass() {
  }

  public myMethod(){
 
  DO STUFF IN HERE
  }

}

you would in your jsp file include this line.
<jsp:useBean class="mypackage.MyClass " id="myObject" scope="page" />

you can now call the method myMethod like so:
<%
myObject.myMethod;
%>

When using beans there are 3 things to keep in mind

1)   you need a package.
      add this statement to all your .java files.
      package mypackage;

2)   your bean statements must be called like this..
      <jsp:useBean class="mypackage.MyClass " id="myObject" scope="page" />

3)   You must be using this directory structure

-jspfiles
-WEB-INF
     -classes
         -mypackage
             -MyClass.class

hope that helps
Cheers,
Ghost
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:jarasa
ID: 10721999
What is exatly what you want to do?
Javier
0
 

Author Comment

by:sdesar
ID: 10724940
Thanks for all the comments from everyone!

I am trying to do the following-

I have Java code that creates a tree view in Java- Treeview I mean Parent tree and when you click on it the folder shows its children recursivly.

I want to create a tree view in JSP now, with the same behavior.

If you can help me exactly with this I will give points to everyone on this querstion since all the answers are good and I will create a new question with more details on treeview.

thanks
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10724981
But is a filesystem treeview?
Javier
0
 

Author Comment

by:sdesar
ID: 10727053
No its from the database and I use Java to getParent, getChildren, getChildCount, etc..
I have the sample JSP page working and the data from it looks something like this
network/   os/  computer/  

if the user clicks on 'computer' the JSP page displays -
network/   os/  computer/
computer1
computer2
...
if the user clicks on 'computer1' the JSP page displays -
network/   os/  computer/ computer1
hp
dell
...

and so on...

- So the tree vie wis working - I need to modify it to use the folders, open folder, close folder images.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question