You cannot instantiate a JSP like that, or use it like that. If you have
included the file and checked the resulting servlet to see whether the
showInclude() method exists, then you should be able to call it, but calling
showInclude. However, if this is what you want to do, then I see no
advantage in having the utility method in a JSP, a utility class would be
more appropriate where you can call a static like (like you are trying to
do).

So try this instead:

<html>
<head>
<jsp:include page="../includes/CheckForConsultants.jsp" flush="true" />
</head>
<body>
...
<%
        <%= showInclude(); %>
%>
</body>
</html>

-----Original Message-----
From: Decancq, Michiel [mailto:[EMAIL PROTECTED]]
Sent: 28 March 2000 12:25
To: [EMAIL PROTECTED]
Subject: Results of the methods-include...


Hi all,

This is the include page :

<%!
static String showInclude()
{
        String vStringToShow = "This is a string to proove the inclusion !";
        return vStringToShow;
};
%>

And this is the page where it is included :

<html>
<head>
<jsp:include page="../includes/CheckForConsultants.jsp" flush="true" />
</head>
<body>
...
<%
        try {
                String vShow = CheckForConsultants.showInclude();
        } catch (Exception ex) {
                        out.println("Something went wrong with the include
:<BR>" +                                        ex.getMessage());
        }
%>
</body>
</html>

The compilation generates NO errors, but when I run it the server yields 1
error, saying that 'CheckForConsultants' is not defined. When I modify the
code however to :

<%
        CheckForConsultants vCheck = null;
        try {
                vCheck = new CheckForConsultants();
        } catch (Exception ex) {
                        out.println("Something went wrong with the
instantiation :<BR>" +                          ex.getMessage());
        }

        try {
                String vShow = vCheck.showInclude();
        } catch (Exception ex) {
                        out.println("Something went wrong with the include
:<BR>" +                                        ex.getMessage());
        }
%>

the server (jswdk1.0.1) generates the error that the class
CheckForConsultants could not be found (+ all the errors resulting from
that).
The result is that the browser gives back a 'The page could not be
displayed' error (internal server error code 500).

Does anyone know how to resolve this ?

Many thanks,

Michiel

Michiel Decancq - partner - Emalaya nv
  O     Tel ++32-2-340 77 30
 OOO    Fax ++32-2-346 42 52
OOOOO   GSM ++32-476-936 315
[EMAIL PROTECTED]

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to