Java and jsp codes

Discussion in 'Java' started by CAESAR, Nov 11, 2009.

  1. CAESAR

    CAESAR Guest

    the java code is:

    package examples;

    public class ReloadedClass
    {
    public static String getMessage()
    {
    return "This is the original message";
    }
    }


    And the JSP code is :

    <%@ page language="java" import="examples.*" %>
    <html>
    <body>

    The message is: <%= ReloadedClass.getMessage() %>
    </body>
    </html>
     
    CAESAR, Nov 11, 2009
    #1
    1. Advertising

  2. CAESAR

    CAESAR Guest

    On Nov 11, 11:31 pm, CAESAR <> wrote:

    Both the files are in tomcat\webapps\root folder


    > the java code is:
    >
    > package examples;
    >
    >   public class ReloadedClass
    >   {
    >      public static String getMessage()
    >       {
    >           return "This is the original message";
    >      }
    >
    > }
    >
    > And the JSP code is :
    >
    > <%@ page language="java" import="examples.*" %>
    >   <html>
    >   <body>
    >
    >   The message is: <%= ReloadedClass.getMessage() %>
    >   </body>
    >   </html>




    The above code is giving an error..... that :

    Unable to compile class for JSP:
     
    CAESAR, Nov 12, 2009
    #2
    1. Advertising

  3. CAESAR

    Lew Guest

    CAESAR wrote:
    > On Nov 11, 11:31 pm, CAESAR <> wrote:
    >
    > Both the files are in tomcat\webapps\root folder
    >
    >
    >> the java code is:
    >>
    >> package examples;
    >>
    >> public class ReloadedClass
    >> {
    >> public static String getMessage()
    >> {
    >> return "This is the original message";
    >> }
    >>
    >> }
    >>
    >> And the JSP code is :
    >>
    >> <%@ page language="java" import="examples.*" %>
    >> <html>
    >> <body>
    >>
    >> The message is: <%= ReloadedClass.getMessage() %>
    >> </body>
    >> </html>

    >
    >
    >
    > The above code is giving an error..... that :
    >
    > Unable to compile class for JSP:


    You should copy and paste entire error messages, not edited fragments or
    paraphrases.

    In what directory is ReloadedClass.class deployed?

    --
    Lew
     
    Lew, Nov 12, 2009
    #3
  4. CAESAR

    Lew Guest

    CAESAR wrote:
    >> On Nov 11, 11:31 pm, CAESAR <> wrote:
    >>
    >> Both the files are in tomcat\webapps\root folder
    >>
    >>
    >>> the java code is:
    >>>
    >>> package examples;
    >>>
    >>> public class ReloadedClass
    >>> {
    >>> public static String getMessage()
    >>> {
    >>> return "This is the original message";
    >>> }
    >>>
    >>> }
    >>>
    >>> And the JSP code is :
    >>>
    >>> <%@ page language="java" import="examples.*" %>
    >>> <html>
    >>> <body>
    >>>
    >>> The message is: <%= ReloadedClass.getMessage() %>
    >>> </body>
    >>> </html>

    >>
    >>
    >>
    >> The above code is giving an error..... that :
    >>
    >> Unable to compile class for JSP:


    Lew wrote:
    > You should copy and paste entire error messages, not edited fragments or
    > paraphrases.
    >
    > In what directory is ReloadedClass.class deployed?


    I ask because in a similar thread you started, others gave you advice about
    putting the .class file in relative path rooted at the class path, and
    "tomcat\webapps\root" is not a class path element. You should review that advice.

    As with any Java .class file, ReloadedClass.class must reside in a
    subdirectory corresponding to its package, in this case "examples/". The
    canonical class path root for web applications is "WEB-INF/classes/" relative
    to the context root. This is all clearly documented in the Tomcat documentation.

    --
    Lew
     
    Lew, Nov 12, 2009
    #4
  5. CAESAR

    code learner

    Joined:
    Dec 24, 2010
    Messages:
    19
    what if you use
    <%@ page import="examples.*" %>
     
    code learner, Jan 9, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg  --
    Replies:
    4
    Views:
    2,280
  2. Replies:
    0
    Views:
    4,548
  3. Replies:
    2
    Views:
    2,990
    Malcolm
    Aug 20, 2005
  4. Allen
    Replies:
    1
    Views:
    684
    Mark Rae [MVP]
    Dec 3, 2007
  5. Replies:
    14
    Views:
    827
    Roedy Green
    Mar 15, 2012
Loading...

Share This Page