Solved

Need Suggestion on re-writting code from JAVA to JSP

Posted on 2004-03-30
7
486 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When Does RestAdapter establishes HttpConnection 5 199
getting Http 404 error in jsp forms 8 73
sortaSum challenge java 17 171
JavaScript parse form with colon separated values 2 73
Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now