Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

more 11th hour stuff

  • 27-03-2001 8:45pm
    #1
    Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭


    I can't get that bloody servlet to work! mad.gif

    It compiles (at last), but keeps giving a 500 (internal server error). I get the same thing from the example in the book, so I'm guessing I'm doing something wrong.

    How exactly do you test a sevlet, without having to actully run a webserver?


Comments

  • Registered Users, Registered Users 2 Posts: 1,023 ✭✭✭[CrimsonGhost]


    Yes you do. Or at least a 'servlet engine'. Not done this myself but
    http://internet.about.com/industry/internet/library/howto/htservlet.htm
    Should help you out.
    Hope that helps smile.gif


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    You gotta run the startserver to test it
    also you gotta restart it if you recompile smile.gif -

    Common stuff:
    are you looking in
    http://127.0.0.1:8080/servlet/yourservletName
    to run the thing ? Does the startserver prog running in the background report any sort of error ?are you writing "servlets" instead of "servelt" in the above URL? are your class files in the "servlets" dir/properly ref'ed ?

    have you edited the servlets.properties file in dir WEB-INF ? you should add a line to the end of it eg
    yourservletName.code=yourservletName
    so that the servelt can find yourservletName.class

    sorry to go over this stuff but its just the sort of piddilin' cr*p that allways goes wrong.

    are you taking in parameters ? maybe its throwing an exzception involving them...


    [This message has been edited by yossarin (edited 28-03-2001).]


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    That looks like exactly what I'm doing. frown.gif

    The book says to use http://localhost:8080/servlet/servletname

    but I'm guessing localhost and 127.0.0.1 are the same thing. I tried it both ways to make sure.

    I am taking in parameters but I tried a file where I wasn't to make sure that wasn't the problem.

    If it's some bloody typo that I'm too bleary eyed to spot.... mad.gif

    Thanks anyway.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    yeah, localhost == 127.0.0.1 useful if you've no network connection.

    Would you mind if i had a look at your code?
    I'm using the same version of jsdk that you are. Using my bat-sense, i predict that it IS some typo...

    incedently if you want to publish later on
    www.webappcareret.com do a poky but free servlet hosting service. they even support SSL.

    anyway, good luck...


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    It won't bloody work frown.gif

    I've only 'till next wednesday to do it. I've a ton of programs based on it lined up as soon as I get this working but it won't work frown.gif

    HTTPGetServlet.html
    <font face="Verdana, Arial" size="2">
    <!-- Fig. 19.6: HTTPGetServlet.html -->
    <HTML>
    <HEAD>
    <TITLE>
    Servlet HTTP GET Example
    </TITLE>
    </HEAD>
    <BODY>
    <FORM
    ACTION="http://127.0.0.1:8080/servlet/HTTPGetServlet&quot;
    METHOD="GET">
    <P>Click the button to have the servlet send
    an HTML document</P>
    <INPUT TYPE="submit" VALUE="Get HTML Document">
    </FORM>
    </BODY>
    </HTML>
    [\QUOTE]

    HTTPGetServlet.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;

    public class HTTPGetServlet extends HttpServlet {
    public void doGet( HttpServletRequest request,
    HttpServletResponse response )
    throws ServletException, IOException
    {
    PrintWriter output;

    response.setContentType( "text/html" ); // content type
    output = response.getWriter(); // get writer

    // create and send HTML page to client
    StringBuffer buf = new StringBuffer();
    buf.append( "<HTML><HEAD><TITLE>\n" );
    buf.append( "A Simple Servlet Example\n" );
    buf.append( "</TITLE></HEAD><BODY>\n" );
    buf.append( "<H1>Welcome to Servlets!</H1>\n" );
    buf.append( "</BODY></HTML>" );
    output.println( buf.toString() );
    output.close(); // close PrintWriter stream
    }
    }
    </font>

    servlets.properties
    <font face="Verdana, Arial" size="2">
    # $Id: servlets.properties,v 1.2 1999/04/02 02:04:22 duncan Exp $

    # Define servlets here

    # <servletname>.code=<servletclass>
    # <servletname>.initparams=<name=value>,<name=value>

    # snoop.code=SnoopServlet
    # snoop.initparams=initarg1=foo,initarg2=bar
    jsp.code=com.sun.jsp.runtime.JspServlet

    HTTPGetServlet.code=HTTPGetServlet
    </font>

    I run the startserver.bat and launch the html file but nothing.

    I've got the .class file in the \jsdk2.1\webpages\web-inf\servlet directory. I've got the path set like the readme says : SET PATH=C:\jsdk2.1\bin;%PATH%

    I don't get it frown.gif


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    That's wierd. Everything there seems to be right. Is the classpath set properly? If you're using the startserver.bat yossarin sent you then it's probably fine.

    What's happening when you click on the 'Get HTML Document' button? Do you get a 500, or a blank page? Do any exceptions appear in the startserver window?
    <font face="Verdana, Arial" size="2">I've got the path set like the readme says : SET PATH=C:\jsdk2.1\bin;%PATH%</font>
    I think that should be the JDK bin directory (c:\jdk1.3\bin or wherever your JDK is installed), not the JSDK \bin directory - there isn't one! Maybe that's the problem, as the JSDK needs to know the JDK path to run.


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    the actual path is : SET PATH=C:\jsdk2.1\bin;C:\JDK1.2.1\BIN;%PATH%


    this is what I'm getting when I click on the 127.0.0.1:8080 link that the 500 error throws up :
    <font face="Verdana, Arial" size="2">
    Error: 500
    Internal Servlet Error:

    java.lang.NoSuchMethodError: javax.servlet.ServletContext: method getResource(Ljava/lang/String wink.gifLjava/net/URL; not found
    at com.sun.web.core.DefaultServlet.doGet(Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
    at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
    at com.sun.web.core.Context.handleRequest(Context.java:375)
    at com.sun.web.server.ConnectionHandler.run(Compiled Code)

    </font>


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    I copied the code and HTML you posted, and it compiled & ran fine confused.gif
    I've done my best to recreate that error, but no such luck. The only difference between your setup and mine that I can see is that you're using JDK 1.2.1, and I'm using 1.3. But the readme says the JSDK has been tested with JDK 1.2, so that's probably not the problem.

    Can you post the contents of your startserver.bat, and how you compile the servlet? It's got to be something to do with them.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    try somthing like :
    set CLASSPATH=,;d:\jsdk2.1\server.jar;d:\jsdk2.1\servlet.jar;d:\jsdk2.1\webpages\web-inf\servlets

    path=c:\jdk1.3\bin

    when setting your paths + compiling
    - ie point the classpath explicitly at each of the jar's + also at the servlet folder

    post your compilign instructions...?

    ps 'druid' ? i like it.
    I wanna be hight priest !

    pps i just looked at you path statments again - defo change them.

    [This message has been edited by yossarin (edited 02-04-2001).]


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    Startsever.bat :
    <font face="Verdana, Arial" size="2">
    @echo off
    rem $Id: startup.bat,v 1.8 1999/04/09 19:50:34 duncan Exp $
    rem Startup batch file for servlet runner.

    rem This batch file written and tested under Windows NT
    rem Improvements to this file are welcome

    if "%CLASSPATH%" == "" goto noclasspath

    rem else
    set _CLASSPATH=%CLASSPATH%
    set CLASSPATH=server.jar;servlet.jar;classes;%CLASSPATH%
    goto next

    :noclasspath
    set _CLASSPATH=
    set CLASSPATH=server.jar;servlet.jar;classes
    goto next

    :next
    rem echo Using classpath: %CLASSPATH%
    start java com.sun.web.shell.Startup %1 %2 %3 %4 %5 %6 %7 %8 %9

    rem clean up classpath after
    set CLASSPATH=%_CLASSPATH%
    set _CLASSPATH=
    </font>

    That bit at the end looks a bit dodgy - like it's clearing the classpath again, but it's probably not run until I run the stopserver.bat

    I'll try using absolute addresses for the classpath instead of relative but I'm not hopeful.

    to compile, the book I'm using says just compile normally : javac HTTPGetServlet.java


    Thanks for all the help guys and keep it coming, please smile.gif



  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    Now it goes straight to the :
    <font face="Verdana, Arial" size="2">
    Error: 500
    Internal Servlet Error:

    java.lang.NoSuchMethodError: javax.servlet.ServletContext: method getResource(Ljava/lang/String wink.gifLjava/net/URL; not found
    at com.sun.web.core.DefaultServlet.doGet(Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
    at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
    at com.sun.web.core.Context.handleRequest(Context.java:375)
    at com.sun.web.server.ConnectionHandler.run(Compiled Code)

    </font>

    without going to the error page before it. I don't get it frown.gif


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    I ran your code as well - it ran fine.

    its either not being compiled right or the servlet server is messed up.

    can you post your *.bat file (I'm assuming windows ?)
    hang in there...


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    I posted the startserver.bat above. I changed the classpath from relative addresses to absolute and it takes me straight to the error page but that's about it frown.gif

    lol at the smiley poping up in the error page tho smile.gif


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    it must be the compile. is the class file made ? + in the servlet dir?

    edit: sorry, you said above that it was...

    nuts, maybe its servlet then...
    where are you placing the java file when you compile ?

    pps how many posts do we have to do untill this becomes a hot topic ?

    [This message has been edited by yossarin (edited 03-04-2001).]


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    lets make this post hot


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    I've mailed you the class file I compiled, so try it out and let us know if it runs or not.

    That startserver.bat is fine, it's the same one I use. It's got to be either the compilation or the servlet classes.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    Jazz are you a crazy 'poster' or a 'poser' ?


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    lol - I don't have no life! I've been here years! biggrin.gif


    Thanks for that class file Jazz, but it didn't work frown.gif

    It must be just my computer frown.gif

    Suddenly I don't want to be a programmer anymore frown.gif



  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Bloody hell, we're fast running out of options here! On the off-chance that there's a problem with your servlet .jar files, I'm going to send you the entire JSDK again. It's the same one as yossarin sent you, but just to be sure...

    If it doesn't work, post the entire contents of the DOS window that startserver puts up and we'll go from there. If everything goes according to plan, it should be:
    JSDK WebServer Version 2.1
    Loaded configuration from file:C:\Programming\JSDK2.1/default.cfg
    endpoint created: :8080
    com.sun.web.core.InvokerServlet: init
    HTTPGetServlet: init
    


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    Its the engine then.
    try http://java.sun.com/products/servlet/archive.html

    and get the 2.1 engine.

    better still - use Jazz'z

    ...im a cool newbie - not just a normal one

    [This message has been edited by yossarin (edited 03-04-2001).]


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    <font face="Verdana, Arial" size="2">Originally posted by yossarin:
    Jazz are you a crazy 'poster' or a 'poser' ?</font>
    What's that meant to mean 'yossarin'? Or should I say 'tosserin'?

    tongue.gif


  • Closed Accounts Posts: 345 ✭✭harVee


    i, was wondering if anyone could help.
    i have a final year project for tomorrow and it's all about doing 3D stuff with a dataglove.
    i've been nerding for days but no cigar...
    harVey


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    thats not nice harVee

    that'll learn you for calling me a tosser

    allthough, throth be tolt i'm in much the same boat myself

    [This message has been edited by yossarin (edited 03-04-2001).]


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    It's for Thursday, not tomorrow. And it'll be ready. Oh yes, it will be ready...

    hows yours goin?


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    I apologize yoss, it was uncalled for.

    anyway, you're just jealous cause I've more stars than you wink.gif


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    I am jealous.

    Messing with the GUI...
    which is fine enough but i want to get some mouse action going...


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    This is what the startserver throws up :
    <font face="Verdana, Arial" size="2">
    JSDK WebServer Version 2.1
    Loaded configuration from file:C:\Programming\JSDK2.1/default.cfg
    endpoint created: :8080
    com.sun.web.core.InvokerServlet: </font>

    and then the IE window gives the 500 error. It shouldn't work, but should I try another browser? Surely the browser would have nothing to do with it.



  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Well it can't hurt to try. And it sounds like the only thing left we haven't looked at is the browser...


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Hang on, it would seem that the InvokerServlet isn't initialising properly, that's when the error is coming up. It's not even getting to your HTTPGetServlet. Did you try the jsdk2.1 I sent you?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    I had to spend all day yesterday getting documentation together, so I havn't had a chance to try it yet. Hopefully later today.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    cool - me and Jazz are around for the day anyway...allthough he's gonna get a nasty shock when he gets kicked out of his lab this afternoon...hehehe

    oh wait - it's you today isn't it - well good luck mate. remember, its all about the showmanship.

    [This message has been edited by yossarin (edited 05-04-2001).]


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    ****ing documentation took ages! eek.gif

    You know college is a mistake when you find yourself saying : "I don't have time for lunch today because I slept last night." frown.gif

    Thanks for mailing me the jsdk Jazz - I installed it on a different computer earlier but no joy frown.gif The same result in the IE window, and in the startserver window. The only difference was when I ran the stopserver.bat it threw up loads of errors and didn't stop the server. confused.gif


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    ummm okay, what's left?
    We're using JDK1.3, so it's possible your problems are because of v1.2.1.
    It definitely works on win95, win98 & win2k, but I'm not sure about ME. what are you using?

    yossarin was saying something the other day about win95 and DOS environment space running out - I dunno the details but I'm sure he'll fill you in soon enough.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    There was somthing about setting the initial enviroment memory of your dos win - see the readme about it. You could try that.
    Ummm, the JDK ? can you change to 1.3 ?
    what OS are you running?

    tell you what - mail us the code & we'll run it - it'll be like the (very) old days where you gave in your punch cards + came back the next morning to see if it compiled wink.gif might take a day or so per compile though...

    Jazz don't forget pub on tuesday.
    yossarin


  • Closed Accounts Posts: 345 ✭✭harVee


    Sorry, can't help, but i thought i'd say hi
    so HI
    c*


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    I'm downloading 1.3 tonight but that couldn't be it, could it? Since the .class file you guys compile wouldn't run either confused.gif


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    It is a long shot, be we seemed to have tried everything else!
    The servlet software still needs to work with the JDK classes since it's just building on top of them, not replacing them. That's why I'm thinking it might be the JDK.

    And even if it's not, we may as well rule it out now. Don't lose hope Blitz, we'll get there eventually! rolleyes.gif


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    hmmm hang on a minute, I just managed to recreate that "java.lang.NoSuchMethodError: javax.servlet.ServletContext" error, except it came up in the startserver window instead of the browser window, as soon as it starts up, and then just as quickly it disappears (trying to catch those dos windows before they disappear is a pain in the ass!).

    Anyway, I did this by removing the servlet.jar (the one that contains ServletContext.class) from the jsdk directory. It's not exactly the same problem you're having, but I suspect they're related. Double-check your paths, and I'll see if I can come up with anything else.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    hey,
    [thinking positive hat on]
    in a way its a good thing that that is the error - its not in your code.

    could you publish any details on:
    where you have:
    jsdk2.1
    jdk1.3
    + exactly what paths you have set in your compile and run batch files.

    I am pretty sure that this is just somthing that we've overlooked.

    ps jazz andy's kids are sick + i got moved back to friday.


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    hah! I don't think you're ever going to get that demo done.


  • Advertisement
  • Closed Accounts Posts: 345 ✭✭harVee


    That's pretty sh!t. Are you the last one in the class Andy ?


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    me n' niall o' toole

    it ok though - I'm happily wasting time on the GUI + not on the writeup


  • Closed Accounts Posts: 345 ✭✭harVee


    Yeah fu(k the writeup. that's what i say. instead of doing it i'm gonna become champ of that golf game leah-ann sent around
    ha ha


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    It's amazing how much time you can lose when your nephew clogs the toilet and floods the house. If there's anything less fun than mopping up toilet water - it's mopping up toilet water while it still rains down on your head frown.gif Ceiling washed and repainted, carpet cleaned and shampooed and it still smells like **** in here! frown.gif

    Anyways - thank god it missed the computers. Though for all the progress I've made it might as well have. Thanks for all your help guys but I'm about ready to give up frown.gif I still get nothing but that Internal Server 500 error frown.gif


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    eventually got it working on one of the college machines about 20 mins before I had to demo it frown.gif Still can't get it working on either of the machines at home frown.gif

    **** it! It's done now biggrin.gif

    Thanks again for all your help guys.


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Hmm the mystery remains unsolved...
    <font face="Verdana, Arial" size="2">**** it! It's done now biggrin.gif</font>
    An excellent policy, I'm follow that one myself.
    smile.gif



  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    I went that way in my demo... smile.gif

    edit: if it worked on any other machine then it must have been some part of your setup/that jsdk..actually, f*ck it, never mind - it doesn't matter

    glad to see that you're working Jazz..

    [This message has been edited by yossarin (edited 30-04-2001).]


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    You lucky bastids! Hmm, just got a 10 day extension on ours...

    Al.


Advertisement