masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API for String. There is a method there, inherited from Object, with the same name as the symbol used in many comparisons. Use that method. (And, yes, I am being purposely obscure.)

Edit: Aaarrgh, and another newb has already given code. Do not give out easy answers without the poster showing some initiative. I can almost guarntee this is some sort of homework/assignment question, and he should do those himself, not just be given an answer.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I`m trying to write a web crawler but i `don`t know how to handle the situation when i have to login to acces a site. How to type in that login form from my java program? I`ve searched on the net but the results points to JSP. I haven`t worked with JSP before, isn`t there a simplier method to complete those user and password HTML fields ??

HttpUrlConnection as a POST request. See http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2006-10/msg01212.html for an example (found in 20 seconds using Yahoo). It is for HttpsUrlConnection, rather than HttpUrlConnection, so strip out the SSL stuff, otherwise, it should be the same.

In summary for you, read the form, finding the different parameters (including the hidden ones), then, using those parameter names, create a POST response and connect again.

Hopefully, you are familiar with the forms already, as I would not count on being able to create some generic login form manipulator.

Edit: And, yes, the code is not that good, and he is complaining that it is not working over a proxy, but it is at least a starting point for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

j@ck@ass swarnamalya poster

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API for Integer and its to.....String methods.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do you mean by "trap" numbers?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You will need a repoduction of a large part of your server code, in your clients, if you really want a direct connection, of course. Then there is also the problem of firewalls, routers, ISP, and any number of other things. Your best bet is to still leave it run over the server, just design some protocol hook in your design that restricts those messages to individual clients, rather than having the server broadcast it to everyone.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Can any one help me in generating a billing report in java without using any reporting tool.
I should get the header, footer and pagebreaks.If the billing takes two pages then header should cum in first page and footer in last page..please help me I would be favourable for u help.

Judging from you other thread, I thought there wasn't much time to get this implemented, and you are still here looking to start? Well, that doesn't seem all that time critical to me anymore. Google for a reporting tool API (such as Crystal Reports or whatever the hell it's called), implement it, and get it over with. By now, you could have already have gotten it done. And if you can't do that, then get on with some coding. I gave you one possible solution (a quick and dirty one, but it would work) in your other thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\Current Version

Will give you the current version and

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\<current version>\JavaHome

Will give you the jre directory. Check up one level from that for a bin/javac to determine if it is a jdk. If that does not exist, then it is only a jre.

Edit: This is, of course, Windows only, which makes it paltform depedent. To try, first for platform independence, try searching for a jre or java on the path from a System.getEnv("PATH") call, but it is, obviously, not guaranteed to be found there. Otherwise, you can use the rpm command to find it on Linux, and pkginfo on Solaris. Other OSes, I couldn't tell you. None of these, however, are truely satisfactory.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Of course, if you have a specific question.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, I know all about javac and java and compiling and executing Java programs... Thats really the first thing I learnt. But I wouldn't expect the end users of my application to go to the command prompt to execute it... They should be able to do that just like ordinary programs. See one of my earlier posts to see what I mean.

If they install Java properly, and you provide them with a jarfile all they need to do is double click on it. No muss, no fuss. The only problem is third party libraries, but that's why they make installers, and there are all sorts of free ones to choose from.

Edit: Then again, if you use an installer, you can have it install Java as well, so that is also a problem solved.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You have done something that has changed the file associations on your machine. (For the jarfile one it was the installation of WinRAR.)

Change them back.

.class should be opened with "java" or "javaw" and .jar should be opened with "java -jar" or "javaw -jar". Alternatively, you could de and re install java and let it reset the file associations itself.

Edit: And java.exe (or javaw.exe) should already be in your path if java is properly installed. If not, add the directory containg them to your path, obviously.

All of these things, BTW, are System Maintenance questions, and not Java questions, per se.

Edit Again: All of these, BTW again, would also be non-issues, if you had learned Java the right way, rather than learning it using an IDE (which is really only learning to use the IDE and not learning Java, as illustrated by these questions).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No. Do your own homework. Read the DaniWeb policies and terms of use.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No. You cannot directly access sockets from an applet. (At least not without changing the security policies on the machine running the applet.) Maybe if it is a signed applet, but I don't believe that even a signed applet is allowed access to sockets. (At least not without changing the security policies, again.)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

<%

Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/database_name?user=user_name&password=type_password&useUnicode=true&characterEncoding=8859_1";
Connection conn= DriverManager.getConnection(url);

Statement stmt=conn.createStatement();
.
.
.
.
%>
like that it goes.........

Hop it will help u.......

That is the old MySQL driver, and is only still present in the distribution for backwards compatability. Use, as the first reply indicated, com.mysql.jdbc.Driver instead of org.gjt.mm.mysql.Driver

Edit: Also, remove all of that scriptlet stuff out of that JSP. It does not belon there. Put it into a bean or some other external object. Anywhere but as a scriptlet in the JSP.

Edit Again:

And DAMN, I didn't notice that this was some ancient post reanimated every two years.

nikhita. The OP made the post four years ago. And the last reply before yours (and mine, unfortunately) was two years ago. I don't think anybody is waiting on an answer anymore.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google "Java file upload", then rather than writing the stream you get from the request to a file, write it to a DB column using the setAsciiStream, setBinaryStream, or setCharacterStream of PreparedStatement, read the API for that method and the Sun Tutorials (or the MySQL documentation which comes with complete examples) for JDBC in general.


And use a Servlet, not a JSP. And regardless of which one you use, the DB stuff should not be a part of it. Rather that should be in a Bean (or some other external object), not the Servlet or JSP itself.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A simple one. Use Courier print face, with 69 (this number comes from the old military reporting guidelines, you can determine this number for yourself, if you wish, obviously) characters per line, design a header and a footer, then determine how many lines are left for printing and break the text up into blocks that size placing the header and footer between each block. If it is suppossed to be done manually, that is the quickest way.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google (or the search engine of your choice) can.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, to tell you the truth, it will probably take longer to rig something up on your own, than it would be to plug in a "reporting tool".

The problem is, you have to format the document for the printer. which means you would have to analyze what is to be printed yourself and determine the page breaks. Any "reporting tool" API will already have done this, and you simply need to use it.

In general, it is quicker to search for, preliminary test, and plug in a third party API than it is to "reinvent" the wheel. There will be times where it is not allowed, has much more than is needed, or is simply to complex, but those are generally the exception to the rule.

And this,

I dnt have time to go for reporting tool

tells me I was right on the money with

you simply want us to do it for you

.

To summarise, it will be quicker (I believe) to find a "reporting tool" than it will be to do it yourself, regardless of the "help"/code you might get here. That code would still need to be analysed and then adapted so it works with your code and for your puposes, and even that alone (even if I were to include a code block) would probably take just as long (or very possibly longer) than it would to plug in a "reporting tool".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What does super have to do with anything here?

Also, it might help to know what error you're getting.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Stay with the original thread, please.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, it looks like you have your requirements, so do you have a question? Or did you simply want us to do it for you?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you are using a server based chat (rather than an everybody to everybody, i.e. with multicast or whatever), then, obviously, you need to have the server accept the message, than send it out to all connected clients. What do you not understand there?

Edit: And, BTW, this

i already created a simple chat server

is not what you said. It would have been extremely advisable to include this sort of information in your first post. That would have definately prevented my last post (which seemd to irk you a bit, admit it). But, like they say, ask a stupid question .....

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The code of magic. Is that like a magicians codex or something. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because 1 != 2. If you want it to enter the if statement only when the input is not 1 and not 2, then you need to use the logical and (&&), not the logical (or).

If you wanted to enter the loop only if the answer is either 1 or 2, then you would use the logical or. i.e.

if ( $ans == 1 || $ans == 2 ) then

but, when you invert the == to !=, then you must also invert the or to an and, because every number is either not equal to one or not equal to two, one and two included.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Best is to use ANT to build your projects to jar files. (or maven if you want to take it a step further).

Once you know how to do it manually, yes. But just like with using an IDE, you should not start with it. You should first learn how to do it manually, so you understand what is happening.

That said, what real difference does it make what tool he uses to build the jarfiles (once he understands what is happening, anyway)?

Making a jarfile was not suggested only for convenience (which the ANT suggestion was). It could be, and probably is, a very real necessity, if any third party libraries are involved.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

i got tat prog from one site while browsing..This is the explanation given in tat

This example demonstrates how to read paragraphs from a CharSequence. A paragraph is a contiguous sequence of non-blank lines separated by one or more blank lines. The lines in a paragraph can be terminated with any of the legal line termination character sequences: \r, \r\n, or \n.

my doubt is where we are giving input para ...??wats tat charsequence.If u understood from above explanation tel me

"inputStr" is the "input paragraph". (as implied by the name)

It seems to be a simple pattern example/test. This should be self-explanatory if you read the API docs for Pattern and Matcher, as already suggested.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You would need to look at the other classes (like Pattern)
It prolly just goes through the code and finds escape characters (\n\t\r) ... you cant tell what it does unless you have the other files

Pattern and Matcher are parts of the JRE. That's why I said to read the API doc for those classes and methods.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Once you install Java, you should be able to "double-click" on a .class file and execute it in that way, if you don't have a class file (but just a .java file), then you have to compile it/them first. Better would be, to create a jarfile containing the relevant classpath info and such in the Manifest file so that every thing is handled correctly, and then "double-click" that jarfile.

Obviously.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why don't you ask the person you copied it from?

Or did you write this yourself, and are having a problem, and so are really asking what's wrong with it? If that's the case why don't you tell what happens that you do not expect.

Also, read the API for the classes and methods used, and then you should be able to figure something out about. If you still are unsure, after that, come back, tell us what you think, and maybe we will help further. But my first point is the relevant one, I believe.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API for SimpleDateFormat and its setLenient method.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It makes no difference whatsoever if you are "rich in java" or not (at least for the first two steps). Sit down and think about what a chat application needs to do, in detail, without any consideration, whatsoever about which programming language might be used.

Once you have figured out what it needs to do, sit down and break these requirements up into "working groups" (i.e. modules) of related functions.

Then you can sit down and start searching through API docs/tutorials/Google for the Java methods you need to implement these functions (hopefully you know at least basic Java, i.e. how to define a class and the varying protection/access modifiers, etc, etc).

Then you can actually start coding. When, at this point, you have a specific question, come back and ask. But we are not going to do any of this work for you. We may nudge you in the right direction from time to time, when you ask (as this response is doing), but we are definately not going to "give you teh codez".

And stop spamming with personal messages. Keep the discussion here so everyone can benefit from it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have you defined one of the following variables in your script anywhere:

IO::Handle->output_record_separator EXPR 
$OUTPUT_RECORD_SEPARATOR 
$ORS 
$\

Because, that "^M" is the "\r" from a "\r\n" windows/dos style line ending rather than the standard "\n" of the unix/linux line ending (at least that is what I have always assumed it to be, since that is what I see when I copy a text file in binary mode in ftp from dos to unix). So, if running the code on a Linux machine produces those in the output file, I can only guess that you have defined one of the above variables to be "\r\n".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

i am creating chat application .can anybody tell me how can i know who is on line on the server and how can i communicate with on line members.

thanks for help

In Other Words: "How do I write a Chat Application?" since the two posted "questions" is pretty much exactly what a chat application is, and possibly implying "Write a Chat Application for me."

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the examples that come with the documentation that comes with the driver that you download.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Convenience.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Show the actual code. The above "process" doesn't really tell us much. For example, what, exactly, is the "necessary file IO"? A FileInputStream, a FileReader, a Scanner? Is that wrapped in a BufferedWhatever? etc, etc.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Show your "second" and "third" method (or at least every line of them that has to do with the hashtable) and the actual hashtable declaration line.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you want to call roll() by referencing the Class (i.e. Classname.methodName() ), then roll() needs to be static. If it is not static, then you need to instatiate an instance of the class in order to able to call the method (i.e. Classname a = new Classname(); a.methodName(); or even for a one-offer (new Classname()).methodName(); ).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm sorry, but if you "know the concept of abstract class", then you know how it "is different from the normal class".

Maybe we should begin with you stating what you believe to be "the concept of abstract class", and what you believe to be "the normal class". Then we can continue on.

The most basic difference, of course, is that you cannot instantiate the abstract class, directly. That does not mean that you cannot get an instatiated object declared as an abstract type, but you cannot directly instantiate the abstract class (except anonymously, in which case it is still not really a direct instantiation of the abstract class as it will be "extended" inline, i.e. the methods are defined on instantiation).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Wow, all that code, and not a code tag to be found.

To be honest with you, no one is going to go through that much code, especially unformatted as it is (use code tags). Try to create a small, self-contained, but complete example that duplicates the problem, and post that code. Many times, creating that example, will result in you finding the solution to your own problem, and hey, that's even better.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

ehmmm, masijade this post is 3 years old:D

The mods got me! ;-)

And, actually, I got myself, as I both flagged and responded to the post, so I made myself look foolish. Oh well, it's not the first time, and won't be the last, either. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I really hope that you (and most definately I) never have to work with any of the bums, I mean students, you help cheat, I mean tutor, their way through their classes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sun's Swing tutorials covers everything you need for this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ask your teacher for clarification. That is what he is there for.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The "hashtable" will have to be an instance variable.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try it. Think of how you might do it, and try it out, then post that if it doesn't work, and we'll nudge you again. Hint: Use Google to search for an SQL reference.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And pay attention to reply number 13. It will make your life soooooo much easier.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, it is possible, and is much more of an SQL question. Have you tried doing it? Post what you have tried.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What rude thing? And because someone responded to your post your offended? What of the above points were incorrect? What of the above points do you have a response to? Oh, you were simply offended that not everyone agreed with your rant?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Honestly, I'm getting more and more disappointed every time I see someone say, "I'm not doing your homework for you." and I'll tell you why...

I've been a programmer for many years now. I've seen many horrible text books, on top of equally horrible professors there are out there - and I've even experienced many myself. Yes, there are going to be those students that really don't want to try, and will go to any length to cheat in order to get by.

And those that want to try will actually try first. Then, if they don't succeed on there own, they will usually use Google first. Then, even if they didn't use Google, they will come here and ask how to do something, providing info about the methods they've already tried. When tey come here and simply provide their homework assignment text (many times nearly word for word), they are simply looking to cheat.

Guess what? Not surprising that they're going to fail, and there's nothing that can be done about that. They will go elsewhere to get what they're seeking. However, there are those who are honestly stuck - even if it's right out of the gate, and they don't know how to start - their books and professors aren't helping, so they turn to the Internet for guidance. This is what help forums are all about: Help. Many people need examples in order to understand how things work - or at least the pseudo code to …