Solved

Need Suggestion on re-writting code from JAVA to JSP

Posted on 2004-03-30
7
485 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
tomcat users xml 7 100
report generation frameworks 1 58
EJB MDB example 4 76
best way to search/remove a file from an EAR file 3 95
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

15 Experts available now in Live!

Get 1:1 Help Now