[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Need Suggestion on re-writting code from JAVA to JSP

Posted on 2004-03-30
7
Medium Priority
?
493 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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