dav mccartney

Ranch Hand
+ Follow
since Feb 22, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by dav mccartney



Thanks so much. Changing to the doGet worked fine. I swore I'd already tried this, but it was late when I thought I made the change so maybe I just did it all in a dream.

Thanks to you both!
dav
18 years ago
Greetings all. I'm trying to do a basic Database view using servlets and JSP, and I'm not quite sure how to solve my current problem.

I've got a JSP (person_list.jsp) that will show all of the people currently in a database. Next to each person, there are hyperlinks to Update, Delete, or Create, with Update and Delete both taking the user ID from the current user and passing it on to... Somewhere? Well, it's appended to the url at this point at least, which I hoped the servlet would "see".

Since the person listing isn't part of a form, I'm not sure how to get the userID to my DeleteUser servlet. I've tried a few things here and there, but nothing is clicking and I get the following message if I try to go to:

http://localhost:8080/PillarTest/DeleteUser.do?userID=1 (or whatever the userID is)

***
HTTP Status 405 - HTTP method GET is not supported by this URL

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
***

I also tried it with a doPost, but that didn't seem to work either. I suspect I'm missing something simple... Any ideas?

Below is the code for person_list.jsp:


and here's the code for the DeleteUser.java servlet:


Sorry for the long post... thanks in advance.
[ August 22, 2005: Message edited by: dav mccartney ]
18 years ago
Ah, I figured it out finally. Turned out to be a combination of using : instead of ; and using the 1.5 sdk instead of 1.4.
18 years ago
I'm working through the Head First JSP book, and all has been going well. However, they're working through breaking things up MVC-wise (chapter 3ish), and now I'm having some problems I was hoping you might be able to help me with.

#1) When executing the following command:

C:\hfj\beerV1>javac -classpath d:\Portable\Pillar\servlet-api.jar:classes:. -d classes src/com/example/model/BeerExpert.java

I get the following error:

Note: src/com/example/model/BeerExpert.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.


But, the file still appears as a .class in my C:\hfj\beerV1\classes\com\example\model directory as expected.
Is this a problem?

# 2) When I execute ths command:
C:\hfj\beerV1>javac -classpath d:\Portable\Pillar\servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

I get the following 9 errors:
src/com/example/web/BeerSelect.java:6: package com.example.model does not exist
import com.example.model.*;
^
src/com/example/web/BeerSelect.java:7: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/BeerSelect.java:8: package javax.servlet.http does not exist

import javax.servlet.http.*;
^
src/com/example/web/BeerSelect.java:12: cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet{
^
src/com/example/web/BeerSelect.java:13: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost (HttpServletRequest request, HttpServletResponse response
) throws IOException, ServletException{
^
src/com/example/web/BeerSelect.java:13: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost (HttpServletRequest request, HttpServletResponse response
) throws IOException, ServletException{
^
src/com/example/web/BeerSelect.java:13: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
public void doPost (HttpServletRequest request, HttpServletResponse response
) throws IOException, ServletException{

^
src/com/example/web/BeerSelect.java:20: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src/com/example/web/BeerSelect.java:20: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
9 errors


If necessary, I've got a .zip file of the directory structure I have setup, and I would love any suggestions or feedback. Their book was written using OS X, so since I'm on XP I'm not sure it there's something syntaxwise I need to do with the classpath statement, but I suspect that's where the problem is.

Thanks in advance!
David
18 years ago
I'm trying to send a quick 2 line, 1 string welcome to players when they connect. On the server side, I have:


And on the client side, I have:


However, when I connect with the client, I'm only getting:

Welcome Player 1.

With no second part of the phrase ("Please..."). Is there a simple fix for this? I'd like to understand what's going on as well

Thanks,
dav

[ September 21, 2004: Message edited by: dav mccartney ]
19 years ago
Thank you, thank you

I'm hoping I can knock out a good chunk of OOP before classes resume...
19 years ago
The new guide looks good... and much less intimidating! Are you trying to *not* scare people away with it?

I agree with Joyce and her reason for printing. I have the "old" version of the guide printed out entirely, which is much easier to do with the older format. Perhaps this could be addressed by providing some sort of printed version in a PDF format? (Anyone that uses a OS X could do the PDFing for you... and I happen to use OS X )

As for the index, I don't actually miss that portion of it. I typically search for my term instead of browsing the index for it. Which also means I don't refer to the printed version I have that often... which also could be a bit harder to do in the newer format as well (but only time will tell).
[ August 28, 2004: Message edited by: dav mccartney ]
19 years ago
I'll chime in here really quick, but I'm sure others will have more to say

You probably want to validate the data before passing it on to the private method. If you look at some of your instructor solutions, you'll see how they've validated early on, well before any other methods are called.

So, if you validate on the outside, you won't have to on the inside (at least in this case)

Also... you'll probably have to have more than 1 method of your own

Good luck to you!
[ August 24, 2004: Message edited by: dav mccartney ]
19 years ago
Glad I could help out, Ray. I worked for the University I'm attending in the area where we did portfolio and evaluations... so when you get to that point, just let me know and I can try to help you out some.

Welcome to the Drive!
[ August 16, 2004: Message edited by: dav mccartney ]
19 years ago
Ray,

I sent you a pretty lenghty private response on my comparison of the 'Drive versus my Univeristy schooling. Hope it helps!

School-approved or not, tho'... I do highly recommend the experiences you'll have while being prodded here.
19 years ago
It appears to work now... but is it really working? As I'm loading my trains to start them, I only create a new train object once, then use it over and over to start trains. Is this really working as it should? Is there a better way to do it?

Here's the code I'm referring to:



I guess, if it is working as it should... I don't quite understand why. My guess is that since I start the train thread before returning a new one, multiple instances are created? Just can't quite get my head around it.
19 years ago
Laugh... wow. Color me sleepdeprived.

Thanks Ernest. That was one of my "I thought I did that already" things.

Snipping the code out just for assignment integrity.
19 years ago
Greetings! This might be more appropriate for the threading forum, but I thought I'd try here first

I have an assignment on threads that's due in about 7 hours. My instructor knows I swear by JavaRanch, and I'm asking him the same question, but I'm hoping someone here might have an idea

The lab is supposed to be an application of Sun's Producer/Consumer Example, but there seems to be something I'm missing.

Here's the output, which hangs after the last line displayed here:

***Train number in the SET method is 1
Train 1 created

***Train number in the SET method is 2
Train 2 created

***Train number in the SET method is 3
Train 3 created

***Train number in the SET method is 4
Train 4 created
Train 1 waiting to enter the tunnel
Train 2 waiting to enter the tunnel
Train 3 waiting to enter the tunnel
Train 4 waiting to enter the tunnel

<snipped for lab integrity>

I notice, when looking at the Produce/Consumer portion of Sun's site, that
the get() returns a value after notifyAll().

When running in Debug through Netbeans, it looks like "available" never gets
touched, but I can't see why. Is it b/c I'm not doing a return? I can't figure out why it's just hanging.

Can anyone offer suggestions or advice?

Thanks!
[ July 09, 2004: Message edited by: dav mccartney ]
19 years ago
Thanks for the post, Jason. I've got finals and final projects for about the next week, so I'm going to step away until I can look at the problem some more. Feels like I need a breath of fresh air
20 years ago
So I sought some outside advice... here's what I got (thanks, oh wise instructor...):

... you could probably change it to three [similar] calls, something like
...Usually I prefer that you don't post code here. If you post great code, you will be robbing others of an education...Marilyn
...


Assuming this is the desired approach, which I'm sure it is since he's all instructor-like... it leads me to 2 questions:
1) Is this headed in the right direction?
2) Assuming it is the right direction... will there end up being a method that massages the number as it is passed, especially in the beginning when billions can kill an int? Or should I just plan on using longs for everything?
If this is the right approach, I guess I'm a bit disheartened. This approach wouldn't have occurred to me.... and I don't know if I should be worried about my abilities, or if I should just chalk it up to being a relative greenhorn in the programming realm...
[ April 03, 2004: Message edited by: dav mccartney ]
[ April 03, 2004: Message edited by: Marilyn de Queiroz ]
20 years ago