Solved

Need Suggestion on re-writting code from JAVA to JSP

Posted on 2004-03-30
7
487 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
7 Comments
 
LVL 1

Assisted Solution

by:gagaliya
gagaliya earned 25 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 25 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven project in eclipse 11 59
String format issue 13 91
'exit' is not valid keyword in java 14 152
maven set up 2 143
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Read about the ways of improving workplace communication.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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