stephen84s 550 Nearly a Posting Virtuoso Featured Poster

How to simulate protocols in Computer Networks

Wow, just when we thought we had seen it all, we are shown new ways (thanks to some of our elite newbies) on "How to not post a question on a Forum !!!"
Looking at this post I bet even Eric Raymond will shred the entire hard disk on which the essay "How to ask questions the smart way?" is stored.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@thariqrasheed

The answer had already been given to you. But your inability to figure it out is at best apathetic.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hi,

I cant save any php file into www. Gives permission error in text editor. But, i can save with using sudo nano ..... in terminal. In the properties of www directory, it permites only root.
How do i solve this problem?

Thanks

Thats because of the file permission system of Linux. It allows only root to write to the www folder because most probably the owner of that directory is root and the permissions for that folder will be 755.

To just allow your user to write to that folder you could do : -

  1. Make the owner of the "www" directory your user, by using the chown command.
  2. Set the permissions of the folder "www" to 757 using chmod command. But this would be a security hazard since anyone and everyone will then be allowed to write to that folder.

And if you wish to know how to use the commands theres always the man <command-name> or info <command-name> to assist.

To get a more in depth understanding of Linux file permissions you can go here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No wonder no one has responded yet to this thread. You have not used code tags while adding your code and have pasted the complete thing, Just looking at the darned thing will most probably chase away anyone and everyone with an intention to help you.
I do not know what is the problem with most of you beginners not using code tags, its as simple as just adding two lines one [ code=java ] before your code and [ /code ] (without the spaces between [(or ]) and code) after it, despite it being mentioned in the community rules and the announcements at the top of the forum.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Exception error, Now thats the most generic term I can think of when describing a problem, Can you be more specific as to what Exception you are getting and at what line number the exception is being thrown as indicated by your JVM ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now from your post I get the impression that you want to hide the following part of the output:-

5264
7021
1741
1556

That would be simple, just comment out or remove the System.out.print() in the following :-

for(int r=0; r<4; r++)
{
	for(int c=0; c<4; c++)
	{
		cards[r][c]=(int) (Math.random() * 8);
		// System.out.print(cards[r][c]);
	}
	// System.out.print("\n");
}

They are the first nested for loops in your code, but honestly you shouldn't be asking us that.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Read my first post carefully, I had said set the content type in your servlet to text/plain not text/html and do you always have to quote the previous message whenever you are replying ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

542

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First of all let me congratulate you on the amazing indentation technique you follow. I think very few programmers in the world survive today who use your indentation technique ... complete left alignment :P.
I suggest you first learn to indent your code. As long as you are doing these kiddy programs you will not have any problems, but when you start writing code even extending to a couple of hundred lines, you will find yourself completely lost trying to figure out which { belongs to which } or where an if block ends etc.
I think you should seriously follow at least some of the coding conventions mentioned by Sun here while programming in Java.
And please give meaningful names to your variables, the sooner you develop these good habits the better it is for your future programmer self.

Now lets see where the problem is :-

System.out.print("\nPlease insert the first card row and column seperated by a comma.");
r1=Integer.parseInt(a.readLine());

Now here you are asking a User to input a row and column number separated by a comma.
But whatever you receive you are directly passing to the Integer.parseInt() method.
Now let me tell you how exactly readLine() works, From your code I get the impression that you think the readLine() method reads character by character which is wrong it actually returns to you the entire LINE of text which was written, so in your case it would be something …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

JSPs should only be used for display purposes in Web Applications, kind off like swing and AWT are used for the User Interface. Your actual programming logic should be written in normal Java class, to the methods of which you will pass your parameters (in this case the word to be scrambled) and they will return back the result. So never put your programing logic inside a JSP.
For this small assignment of your you may think the above advice is an overkill but its always better to start using the right approach as early as possible.
By checking out your code I suggest you use consistent indentation. There are some places where you have indented correctly whereas at other places you have just conveniently just forgotten about it. You can read here about the code conventions recommended by Sun while programming in Java.

Also look at the following piece of code:-

if (guessed == target){

target and guessed are both String objects. The == operator for in case references to objects checks if target and guessed both point to the same String object. So guessed == target would evaluate to true only in the following case : -

target = new String("jack");
guessed = target;
if (guessed == target){

But you need to check if the contents of the two strings target and guessed are the same. So for that you need to use the equals() method of the String class (or equalsIgnoreCase()

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Your <select> element (and also any other element eg textfields, checkboxes, etc ) should be inside the <form> </form> tags, if you want your data to get posted (via GET or POST) to the URL specified in the form's action parameter.
From what I see you seem to have no idea how HTML forms work, so I would suggest this tutorial.

And PLEASE use code tags, when you are pasting code. You can read about them here.
This is already your fourth post in roughly 7-8 months and the fact that you still haven't read the rules only shows your ignorance.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

538

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Celebration - Birthday

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Not bad suggetion my friend.

But i want to deploy immidiate this one i mean to say if u have any immidiate souce then it will be helpful to me.

may be now u understand.

regards,
Sm3128

What I understand is quite simple, you wish to take mine or someone else's code and show it off as your own and that is something no one will help you on , especially in this forum.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

<ignore>

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

This link will help you on how to configure NowSMS to read incoming messages and forward them on to an HTTP URL (which could be your servlet, JSP whatever).

I had already told you in one of your previous threads to check the reference manual of NowSMS for that, but it seems like you are just more interested in ready made answers.

In the URL (JSP / Servlet / ASP / PHP /...) that you make (and set in the "Command to Execute" field) all you have to do is set the content type to "text/plain" and whatever text you return in the response will be sent back to the user who sent the message.

Also I had already mentioned it to you that your SMS speech is irritating, this is the last post of yours I am reading if you keep it up.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Then check this link out, It should help you out for facebook. Similarly you can check for Linked-IN and others

Why should I or anyone else give you ready made code for something that is assigned to be done by you either at your workplace or as an assignment.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

posible if yes the plz provide me source for the same.

Here is the code which you can use directly without too much modification.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@babusek
This is your twentieth post and still you have not used code tags. Are you just plain ignorant to not go through the Community rules or the Announcements or at least observe how other posters post in the forum.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Would you please care to elaborate more on that ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

> Thread.getThread().sleep(3000); //Pause for 3 s Thread.currentThread().sleep(3000);

That would give you a warning since sleep is a static method and from what I have seen applies to the current thread only, So its got to be:- Thread.sleep(3000);

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My name is Jennifer and i love computers. I am into programming but i struggle a bit with it. I am 22 years old, i have a nice boyfriend, i am Haitian living for the moment in the States to complete my degree. i love reading, sleeping, dancing and eating. i hope that i will meet new people. kisses

Sheesh, I guess we should dwell in the Community Introductions section more ..... :P

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Sorry Stultuske but my first post already does what you are recommending in your post.
But the following line in his second post contradicts what he says in his first post:-

i wonder if i could not have all the words of the array appearing at the same time

So here he does not want the entire content of the array to be displayed at the same time.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

but i wonder if i could not have all the words of the array appearing at the same time

What is it that you want exactly, your question is just too generic, I do not know what to make of it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The following piece of code:-

label3.setText(arrayOfTen.get(i));

Replaces whatever previous value you have set for the label with the new one you have specified here.

Use this in case you want to also retain the previous content of the label:-

label3.setText(label3.getText() + " " + arrayOfTen.get(i));

And please use code tags when you are posting code. All you have to do is put your code inside [ code=java ] and [ /code ], its is already mentioned in the announcement at the top of the Java forum.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Honestly I do not see anything of JSP in your page, just Javascript.
And following is what you can use to encode your field

var encoded_data = escape("<string_data_to_encode>");
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Using NowSMS you can only send SMSes from a cell phone to the PC to which your Cell Phone is connected and is being used as GSM Modem. You cannot send SMS from one Computer to another without each one being connected to its own cell phone with NowSMS configured on both the machines to use the cell phones as GSM / GPRS modems.

Also In case you just want to send outgoing SMSes (from the PC which has your cell phone connected) to any other cell phone, NowSMS has a Web Interface which you can use for that. In case you wish to embed this ability of sending messages in a program of yours, it also has a HTTP link for accepting messages to be sent via your cell phone, you can embed this link inside your application, you will need to check out the NowSMS reference manual however to check the link specifications though.
As far as receiving SMSes via NowSMS goes, I haven't really tried it, so can't help you on that.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

As usual your post is vague and I can't exactly figure out what you need !!!

Let me guess what is the scenario here:-

Your Cell Phone is connected via a USB / Serial Port to your PC and has been as a gateway in NowSMS and you wish to write an application (servlet / JSP ... whatever) from which you can send an SMS to any mobile phone using your cell phone as a GSM Modem ???

OR

Is it the other way around and you wish to retrieve messages received on the Cell phone via NowSMS and NowSMS should forward the SMS to your HTTP Link (which could be JSP Servlet whatever ..)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

well if the problem has been solved it would be appreciated if you mark this thread as solved.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

In Java null and "" are not the same thing.

null is the actual universal NULL, i. e. nothing.
On the other hand "" is a blank String object.

If an object is "null" calling any method on it would give you a NullPointerException, hence we need to first check for null and only after that we check if the String is "blank".

"null" I assume is returned when the parameter is not present at all in the request (which is not your case), but you had mentioned encountering a NullPointerException earlier, thats why I recommended both the conditions for your case.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Ok.. What was the output when you replaced

if (request.getParameter("UserName")!=null)

with the following condition:-

if ((request.getParameter("UserName")!=null) && !(request.getParameter("UserName").equals(""))) {
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My first suggestion would be do not this task inside a JSP. JSPs are only for making your user interface, the processing i. e. your "scp" should be inside a Java class.
Second suggestion is instead of

scp /sx04a1/jakarta-tomcat-5/webapps/maltixa/index.jsp jipbekok@fff04.ff.ff.es:/sx04a1/jaka...ixa/index5.jsp [/code]

give it the absolute path of the "scp" binary on your system like this :-

/usr/bin/scp /sx04a1/jakarta-tomcat-5/webapps/maltixa/index.jsp jipbekok@fff04.ff.ff.es:/sx04a1/jaka...ixa/index5.jsp[/code]
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

eventhought.... same thing!

i am really confused!

Have you tried by changing the name of the field from "UsrName" to "UserName". Next show us your servlet code and why you feel that the code inside the "if" block is getting executed.
Note when pasting your code use for java code and [code=html] for HTML, it provides syntax highlighting.[code=java] for java code and for HTML, it provides syntax highlighting.[code=html] for HTML, it provides syntax highlighting.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So where are you encountering a problem ??
We are not Psychics to know what output you are getting on your computer screen.

Tell us the problem in clear words and we will see what is going wrong.

Also in the first servlet:-

if(rs.next()) {
        mobileno=rs.getString("mobileno");
        password=rs.getString("password");

why do you simply want to get the mobile no. and password from the database when you know that the mobile no. and password that you have is correct (cause it has already been validated by your SQL query).

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

There is your problem

<input type="text" name="UsrName" maxlength="15" size="15"/>

Check the Spelling of the name given to the field, you have give "UsrName" it should be "UserName".

But it should not enter the if block as the condition ( (request.getParameter("UserName")!=null ) )still evaluates to false.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Thats strange the NullPointerException would be thrown only in case request.getParameter("UserName") returned NULL, but in your first post you had said request.getParameter("UserName") != null evaluated to true for all cases.

Try the following condition:-

if ((request.getParameter("UserName")!=null ) && (! request.getParameter("UserName").equals(""))) {

It should accommodate both conditions when you get a blank as well as when you get a null.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Can you show me the code of the page where your text field is located.
Have you set the default value for your text field to a blank string i. e. ("").
In that case the check for (!= null ) would fail even if your text field was blank. You would have to check for blank string in that case like this :-

if((! request.getParameter("UserName").equals(""))) {
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Ok... Now I am going to just assume how you wish the servlet should work, If you have an already registered user, you want to just display "You are a valid user" and if the user is invalid you want to display "Please register !!".

So lets see where you could be going wrong:-

String sql = "select mobileno,password from newuser where mobileno='"+ mobileno + "'and password='"+ password + "' " ;

Now the above query would return you a database record if and only if you got a valid user with correct mobile number and password hitting your servlet.

So instead of while(rs.next()) you should instead opt for if(rs.next()) like this :-

if (rs.next ()) {
  // If we get a record it means the (mobileno & password) 
  // combination is already valid.
  // so just close your statements and do whatever you want
  // for a valid user here.
} else {
  // No records found for user in table, so user is invalid.
  // So put the appropriate message for invalid user and
  // the registration link here
}
javaAddict commented: Nice call +3
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Tell us exactly whats going wrong and how do you want the servlet to behave ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Iam ..sorry.. really i dont know how to use [code] tags .. plz i will go through those code tags it now...from next time i will follow code tags definately... plz check that this time...

No I am not, I gave you the link in my first post, if you cant find it then see this :-
http://www.daniweb.com/forums/announcement9-3.html

Edit your post and add the code tags to it, it should not take more than a few minutes.
And PLEASE write the full words why do you eat up sentences with the "..." and the SMS language(used with Mobile handsets) when you have a complete keyboard in front of you.

And you have not even mentioned what is going wrong now, after you changed your query.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Am not looking at that post until you start using code-tags to wrap your code. I already mentioned it to you in my first post, but you just wish to keep ignoring it and please start writing your posts in English. The SMS speech and the "..."s you are using are irritating, I guess that would not be too much to ask.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Any specific need for rejuvenating an old thread which has already been marked as solved ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Surely that's up to them? And that marks the difference between the beginnings of a good programmer and a Google-Leech? Surely we have to let people make their own decisions?

Yes, and in the same way our decision is to help them change from being a leech, by pointing them in the right direction, rather than just feeding them more blood.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

but i want to compare dynamically ..if i give particular number then it displays those results.. but if i give another number then i have to change that in servlet also...i want dynamically if mobilenumber enterd in jsp then it should be checked with db and comapres with enterd value.. if its there dispaly already existed if not register..how i should i do this?

If you would just merge my query with your code wouldn't it do the same or you need me to spoon feed you the exact java syntax, then here it is :-

String sql = "select password from newuser where mobileno=" + mobileno;
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

As far as your problem goes you need to put a "where" clause in your select query like this:-

select password 
from newuser
where mobileno='<the value that you got in your request>'

So your "while" will be entered only if the mobile no is valid (and if valid give you the password of only that "mobileno" )and you just have to check whether the "password" is valid in your "if" condition.

Also I can see that you are overwriting the value in the variables "mobileno" and "password", first you are storing in the value you get from the request here:-

String mobileno=request.getParameter("mobileno");
String password=request.getParameter("password");

And then you overwrite them if the corresponding values you get from the database here:-

while (rs.next ()){
  mobileno=rs.getString("mobileno");
  password=rs.getString("password");
}

Also another suggestion do not use user mysql "root" login to do such trivial tasks. Use root is only for when you have to perform administrative tasks on your database, for normal use create another user account.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

<EDIT> Ignore please ............. mixed my tabs again :@

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So that you can Spam them .... Nice try.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Just a thought, instead of writing each object after serializing one by one to the file, why don't you just serialize the entire ArrayList and write it to a file.
And when you need to add any data to the file, get the ArrayList back from the file, add the object to the ArrayList and serialize this ArrayList overwrite the older file with the file containing the new ArrayList

Alex Edwards commented: A nice idea - Serialize the objects in a collection (though I disagree with using ArrayList in this case @_@ ) +5
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No I dont, because this guy is not the first one who has posted this query, and from our experience with other people in the past if you give them the "QUICKFIX" like you have, they simply disregard whatever else you have said and just apply the QUICKFIX to their code ..... and then they will come back again and again shamelessly with the same JSP code jumbled up with database connections and what not.

And thats exactly the reason why Peter (who has got 10^1000000000000 times more patience than me) also did not give the thread starter the QUICKFIX, but you anyway had your own ideas.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Actually, he wasn't asking about how to organise his web apps. He was asking a very simple question about database connectivity.

vivek_web:
Is your DSN definitely set up correctly? Also, try adding username/password details into the connection URL. For example:
jdbc:odbc:db;ID=username;PWD=password

A physician gives you the medication you need not the one you want. Similarly I knew exactly what the thread starter wanted, but he actually needed someone to show him how to code JSPs first like Peter mentioned and thats where I have pointed him to and finally just for the record your suggestion is nowhere near the solution.