Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java Bean Browser

Posted on 2000-03-15
10
Medium Priority
?
357 Views
Last Modified: 2013-11-21
I am writing an Java application that I would like to display html and jsp pages within a JPanel.  Does anyone know if a bean exists to do this and where I can get it?
0
Comment
Question by:mpoisson
[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
  • 5
  • 5
10 Comments
 
LVL 4

Expert Comment

by:jerch
ID: 2619516
Use JEditorPane.  It supports HTML 3.2

JEditorPane1 htmlPane = new JEditorPane();
htmlPane.setName("My HTML Pane");
htmlPane.setBounds(0, 0, 400, 400);
htmlPane.setEditable(false);
htmlPane.setPage(<url>);

The setPage() method can either accept URL or String.

sincerely yours
Jerson
0
 
LVL 4

Expert Comment

by:jerch
ID: 2619533
By the away add it in a JScrollPane.

scrollPane.setViewportView(htmlPane);
0
 

Author Comment

by:mpoisson
ID: 2620142
Can this htmlPane also display JSP(Java Server Pages)?  
0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 4

Expert Comment

by:jerch
ID: 2620175
Definitely, since jsp generates html. The jsp code is not actually returned. Likewise, it supports ASP.  The important thing is that the page generated only contains html 3.2 tags.  Otherwise, it will not be able to display or display properly the page.

Jerson
0
 

Author Comment

by:mpoisson
ID: 2620186
Can this htmlPane also display JSP(Java Server Pages)?  
0
 

Author Comment

by:mpoisson
ID: 2620689
I have tried this out, and it there seems to be some problems using forms.  A submit button generates a null pointer exception coming from the java package javax.swing.text.html.FormView.  I am not familiar with the EditorPane are we asking too much of it?
0
 

Author Comment

by:mpoisson
ID: 2620813
I have tried this out, and it there seems to be some problems using forms.  A submit button generates a null pointer exception coming from the java package javax.swing.text.html.FormView.  I am not familiar with the EditorPane are we asking too much of it?
0
 

Author Comment

by:mpoisson
ID: 2620815
Adjusted points from 200 to 400
0
 
LVL 4

Accepted Solution

by:
jerch earned 1600 total points
ID: 2621916
Hello there... No you're not asking to much. It's actually because we have different time zone. :-) Your last post here was actually 2am here.

Anyway, I prepared a code for you. Check this out. This is the code for the html and make sure that you have all the syntax correct since I've tried it out and it supports form submission.  It will throw exception if it encounters unrecognized tags or wrong syntax such as having <\body> instead of slash you have back slash.

<html>
<body>
<b>Please Log in</b><br>
<form action="/servlet/Login" method="post">
Username:&nbsp;<input type="text" name="username" size="20"><BR>
Password:&nbsp;<input type="password" name="password" size="20"><BR>
<input type="submit" value="Log me in!">
</form>
</body>
</html>


On the other hand, this is servlet that the form submits to.

import java.io.*;

import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Login extends HttpServlet {
    public void doPost(HttpServletRequest req, HttpServletResponse res)
            throws IOException, ServletException {  
        PrintWriter out = res.getWriter();
        out.println("Username:&nbsp;" + req.getParameter("username") + "<br>");
        out.println("Password:&nbsp;" + req.getParameter("password") + "<br>");
        out.close();
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res)
            throws IOException, ServletException {
        doPost(req, res);
    }
}    

So if I were able to make it work in servlet.  It suppose to work with JSP.  Since the JEditorPane does not care what server side program processes the form.


And this is the last program that you use to view the HTML

import javax.swing.*;
import java.net.*;
import java.io.*;


class HTML {
   
    public HTML(String url) throws IOException {
        JEditorPane htmlPane = new JEditorPane();
        htmlPane.setName("My HTML Pane");
        htmlPane.setEditable(false);
        htmlPane.setPage(url);
       
        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setName("scrollPane");
        scrollPane.setBounds(0, 0, 640, 480);
        scrollPane.setViewportView(htmlPane);
 
        JPanel panel = new JPanel();
        panel.setName("panel");
        panel.setLayout(null);
        panel.add(scrollPane, scrollPane.getName());
        panel.add(new JButton("OK"), "button");

        JFrame frame = new JFrame();
        frame.setName("HTML");
        frame.setBounds(0, 0, 640, 480);
        frame.setTitle("HTML");
        frame.setContentPane(panel);
        //frame.setResizable(false);

        //frame.pack();
        frame.setVisible(true);
    }
   
    public static void main(String[] args) throws Exception {
        HTML html = new HTML("http://localhost/");
    }
}

Hope this helped.

Sincerely yours,
Jerson
0
 
LVL 4

Expert Comment

by:jerch
ID: 2623595
thank you...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
What You Need to Know when Searching for a Webhost Provider
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

598 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