Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2008, 04:46 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 687
Nicholas Jordan is on a distinguished road
[SOLVED] base directory for servlets
I spent half a day getting a temp placeholder servlet to compile. Let alone whether it will run or not, I put it in /home/******/webapps/ROOT/WEB-INF/classes

Is this correct?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-04-2008, 01:44 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 459
fishtoprecords is on a distinguished road
This is one of the reasons I use NetBeans. It makes a .jar or .war, you just put it where Tomcat wants, and a miracle happens.

The whole jar, .ear, .war stuff drives me crazy. Its different, sort of, but not really. I can't ever remember where anything goes from one thing to another.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-04-2008, 02:05 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 687
Nicholas Jordan is on a distinguished road
crazy drivers
Short version:
One has to put /servlet/ in the url or do an xml mapping.

Longer version:
I have to get up on the front burner on xml due to a need for it.

As for the drivers ( here ) I had to go back and get the NetBeans that had the Web stuff. When I ran the installer it refused to overwite the previous install even though I wanted it to. In so doing, I had to obtain a random port for admin port for one of the servers. I already had a utility written. I know you will say something because I did not use java.security.SecureRandom, but this is dramatically better than fingers-pounding-keyboard or guess or accepting what is in the setup and install script:
Code:
import java.util.Random;// import java.net.*;// /* USE OF THIS CODE CONSTITUTES DISCUSSION OF OPINION IN A TECHNICAL FORUM * NO SUITABILITY FOR ANY USE IS IMPLIED BY READING THE OPINION PROVIDED. * * Reader assumes the risk of any use. * * Simple client/server Socket selection program. * * The Dynamic and/or Private Ports are those from 49152 through 65535 * Source: http://www.iana.org/assignments/port-numbers * The port numbers are divided into three ranges: the Well Known Ports, * the Registered Ports, and the Dynamic and/or Private Ports. */ public class PortSelector extends Socket { private static final Object lock = new Object(); int port;// // Private Ports are those from 49152 through 65535 static final int range = ( 65535 - 49152 ); InetAddress iwannaBanna;// public static Socket sockitToEm;// /***************** always put some random stings in your code *****************/ /***************** it's more fun that way and makes peole think *****************/ /***************** you know what your are doing. *****************/ java.lang.String a = "06d98abff66495089d23f269cf296b783f5499e8b1b75fabc97e417f5319ba2f"; java.lang.String b = "fffb0d5f946240499dd413202c8567f070d32672ece45f75249164ece47b2c3e"; java.lang.String c = "7b29d40b262212abea99171af1c197835297c17a7361f2a5b371a8146f8340c3"; java.lang.String d = "3657e092450b24d7f3542df00daa7f4a445dbd2baa7064f2bbdd165a7ad16b58"; PortSelector() // { // Extensible super();// } // public static synchronized Integer getPortNumber() { Random candidateInt = new Random();// port = (candidateInt.nextInt(49152) + range); if((port < 49152) || (port > 65535)) { cadidatePort = (candidateInt.nextInt(49152) + range); } while((port < 49152) || (port > 65535)); return new Integer(port); } // public static void main(String[] args) { System.out.println(new PortSelector().getPortNumber().toString());// } }
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-04-2008, 02:17 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Gone to Costa Rica
Posts: 2,223
Norm is on a distinguished road
Looking at this code, I didnt' think it would compile because of port being non static. I tried it and it didn't.
Why the new if the methods are static?
Quote:
new PortSelector().getPortNumber().toString());//
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-04-2008, 02:24 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 459
fishtoprecords is on a distinguished road
Quote:
Originally Posted by Nicholas Jordan View Post
Short version:
One has to put /servlet/ in the url or do an xml mapping.
Yeah, you have to glue your code in, servletmapping in the XML files is where I usually do it. I tend to forget these little details, as I tend to not have a lot of serlet entry points, and netbeans will add them properly for me with you do the new -> servlet generator
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-04-2008, 02:51 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 687
Nicholas Jordan is on a distinguished road
processRequest
I cannot see all of your reply, fishtop, but yes@details always seems to fishtail.

Mangaged to get up in NetBeans with Web and pasted my previous sources directly into a base jsp with only one ( so far ) issue in hundreds of lines. An ommited list element in a font tag. I consistently get the mental visual of an elephant. { basically the same one I mentioned earlier }

I have got a base page with
Code:
<form action="TemporaryOrderForm" method="post">
coded in for protoyping and development all ready, so I just use that a drop-in as soon as I can get template servlet code from the IDE. What I need to do here is establish whether this processRequest method ( which it came up with for template code ) is called by doPost behind the scenes. I chose Tomcat during the install, that's what the commercial server uses. I have code written - ready for testing - already in doPost with some logic to write a base page if several form fields do not come in. Something along the lines of
Code:
<form action=testServlet><input type="hidden" value="( semi-random string )"
If this and two or three other parameters are non-null and match up here and there, we go to the SecureRandom store and get a sessionID as well as pull one from the Server and all I am doing is playing with kittens.

Paranoia not only strikes deep, it as well has inversions. If the user-agent does not make it past those, this processRequest method as they have it is the approach of choice. I have the code, ready to drop in it, provided I can make is so that we either do processRequest or doPost but not both.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-04-2008, 03:08 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 687
Nicholas Jordan is on a distinguished road
looks stupid, works great.
Quote:
Originally Posted by Norm View Post
Looking at this code, I didnt' think it would compile because of port being non static. I tried it and it didn't.
you need to get a better compiler. Tool Output:
Tool completed successfully

Here, hava a port number: 56674

Quote:
Why the new if the methods are static?
new calls PortSelector() which we say that constructors do not return anything, but new 'returns' a PortSelector 'object' on which we may then call the method '"getPortNumber()" which retuns an Integer from the java base libraries, on which we call .toString directly in the print statement in main.

Spending time on code correctness while I had an installer open would have been premature optimization. I have much stronger words, mabye I better have some of your beer. Got wheat beers? Medium body, medium everything all the way through.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-04-2008, 04:49 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 687
Nicholas Jordan is on a distinguished road
How's this for glue?
I got a full build with one placement of a semi-colon statement terminator. I tried to save the build log so that you could look at it but I have an OO failure, clear and present:
Code:
http://localhost:8084/Kochi/TemporaryOrderForm
Kitty and Kochi map to the same thing.

Sort of a cute moment, the real world likes that.

Pretty good for one of those code-bloated IDE's.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 07-04-2008, 06:13 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Gone to Costa Rica
Posts: 2,223
Norm is on a distinguished road
This compiles and executes:
Code:
PortSelector.getPortNumber().toString()
static methods don't require an object
port not being static can't be referenced from a static method

Besides the fact that:
Code:
while((port < 49152) || (port > 65535));
will loop forever it port is out of range?

Am I looking at the same code as you are?
Why post code with so many errors?


My beers were/will be British ales.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 07-04-2008, 08:09 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 687
Nicholas Jordan is on a distinguished road
well, yes .....
Quote:
Originally Posted by Norm View Post
This compiles and executes:
Code:
PortSelector.getPortNumber().toString()
static methods don't require an object
port not being static can't be referenced from a static method.
Well, yes, I could have called getPortNumber() directly from main() ~ I was in a hurry. It did run, I did get a port number. The fact that I went through a call to new sort of blurs our discussion, yes but even with an object:

PortSelector portSelector = new PortSelector();

I can still call getPortNumber on portSelector. It is a matter of a few instructions to access a variable sized memory allocation called the heap. An early form of failure in programs called stack crash was when the heap would grow so big as to overrun the physical addresses where the running program stacks things up.

Because I was using Java, I could just code something to get a random port number and prototype not worrying about matters like that. If it failed, I just get an Exception and main() returns control to the JVM without breaking my machine.


Quote:
Originally Posted by Norm View Post
Besides the fact that: while((port < 49152) || (port > 65535)); will loop forever it port is out of range?
This method of searching is extremely powerful when the size of the dataset vastly exceeds the search window available. We have a call to next random in there somewhere, if not you have a valid point. These rarely go past a few milliseconds to get something in range. You can try narrowing the window but I promise up front on the board that no book you can find will ever tell you how to sit on the keyboard without trapping a Thread in a while() loop. While loops consume processor power, power that is needed if we are to keep the machine responsive. A good exercise would be to put a ++int if int greater than loop limit, discard request and report failure to System.out

I coded something that sits on the keyboard to watch for keystrokes but consumes almost no processor power. Good exercise for you. Work on it, post in beginner and read Algorighms in Java by Sedgewick. Really effective tool for someone with your skill level.

In fact, one could focus the search window on some specific area of the dataset by using a next Gaussian method already available in the libraries. Tell ya what, Bocephus, center my search on the desired range using a next Gaussian. While you are sitting there in an all night hair puller be sure to Amazon a copy of Sedgwick's masterwork. Some of the techiques in Cave Oriented Bloated Oh Languge can be prototyped in Java very effectively using the cited work. Doing so will prevent moderators watching me suffer your unresearched stumbling.

( Pro's here folks, don't worry about it )

Quote:
Am I looking at the same code as you are?
Probably, but I think you need to look a little closer.

Quote:
Why post code with so many errors?
What error, where? Here, hava port number:
Code:
62060
I think it is in hexadecimal ~ that was the first toString I found in the sources. Help me here, boss -> did I call toHexString(int i) or call toString(int i)

Quote:
My beers were/will be British ales.
Those tend to be too stout and bitter for me. I need a moderately smooth Lager.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 07-04-2008, 11:19 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Gone to Costa Rica
Posts: 2,223
Norm is on a distinguished road
Quote:
Running: C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe -deprecation -g -Xlint PortSelector.java

PortSelector.java:42: non-static variable port cannot be referenced from a static context
port = (candidateInt.nextInt(49152) + range);
^
PortSelector.java:43: non-static variable port cannot be referenced from a static context
if((port < 49152) || (port > 65535))
^
PortSelector.java:43: non-static variable port cannot be referenced from a static context
if((port < 49152) || (port > 65535))
^
PortSelector.java:45: cannot find symbol
symbol : variable cadidatePort
location: class PortSelector
cadidatePort = (candidateInt.nextInt(49152) + range);
^
PortSelector.java:47: non-static variable port cannot be referenced from a static context
while((port < 49152) || (port > 65535));
^
PortSelector.java:47: non-static variable port cannot be referenced from a static context
while((port < 49152) || (port > 65535));
^
PortSelector.java:48: non-static variable port cannot be referenced from a static context
return new Integer(port);
^
7 errors

7 error(s)
I guess I need a better compiler. Mine is too literal. It needs to figure out what the coder entended and fix it.

Where does port get changed in the while statement?
while((port < 49152) || (port > 65535));
It appears to be a standalone while, not part of a do{}
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 07-05-2008, 01:29 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 687
Nicholas Jordan is on a distinguished road
try this
Code:
import java.net.URL; public class EatHumblePie { private static String Earl = "http://www.highgravitybrew.com/productcart/pc/configurePrd.asp?idProduct=2546";// // Member function of Class EatHumblePie public static synchronized Integer getPortNumber() { // Standard Library call. Random candidateInt = new Random();// // Get first int value, should be in range of 49152 to 65535 int candidatePort = (candidateInt.nextInt(49152) + range); // If candidate port is not between those values, like if // I blundered the previous line.... if((candidatePort < 49152) || (candidatePort > 65535)) { // Then do { candidatePort = (candidateInt.nextInt(49152) + range); } while((candidatePort < 49152) || (candidatePort > 65535)); } else { // .... URL earl = new URL(Earl); } return new Integer(candidatePort); } // public static void main(String[] args) { // Default constructor from compiler EatHumblePie ehp = new EatHumblePie(); // Get an integer from static context Integer SelectedPort = EatHumblePie.getPortNumber(); // Print the integer to the console. System.out.println(SelectedPort.toString());// } }
This is near trivial compared to getting one of those IDE's to go in the same general direction as the intent the project was designed for. To answer your central question the nextInt(int value) gives us an integer between zero and the value passed in the function call. Admittedly I was running a previous build, the code I put up was done in dire straits. I would not have done that with any other programming tool. Finding all this stuff in a project can become involved, all the details have to be carefully preened again and again.

I sort of thought it trivial to recognize the do loop and the if and how the thing works overall. The do loop as I have it now will likely never be reached, but it is a standard engineering line of code that returns a number between two values. It sort of reverses.

UpperBound - LowerBound == Range.
Integer anInteger = Random.nextInt(Range) + LowerBound;

That is around the level when I went in Second grade and they told me how to spell Apple on the first day of class. Can beer be made from Apples? Sorry if I wasted any of your time, I sort of get acclimatized to expecting everyone can see what I intended. Try reading an RFC in thirty minutes and getting a fundamental grasp of a subject you have never worked on before in that fast-paced environment. that is what took me away from going back and editing the code.

EDIT:
Marty, I am trying to do some super fragilistics - can we edit and delete my earlier poor code? I sort of see all conditionals as a branch and just rue the day they made goto goaway.

Last edited by Nicholas Jordan : 07-05-2008 at 03:48 PM. Reason: poor code in earlier post
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
servlets or jsp krishnapal Advanced Java 1 12-13-2007 04:31 PM
Problems with Jtable connected to data base elizabeth AWT / Swing 2 08-07-2007 06:24 PM
Problems when I try to connect to data base gabriel Database 1 08-06-2007 07:38 PM
2 threads sharing a data base connection Ed Advanced Java 2 07-04-2007 06:41 AM
Connection to data base Daniel Database 2 06-07-2007 06:55 AM


All times are GMT +3. The time now is 01:53 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org