• Post Reply Bookmark Topic Watch Topic
  • New Topic

From web to util.Scanner  RSS feed

 
henke anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you get input from your jsp to your Scanner ?
 
Knute Snortum
Sheriff
Posts: 4200
122
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you will get more responses if you TellTheDetails (that's a link).
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a guess please. Do you mean to catch the requestParam from JSP then pass to Scanner for further business logic code ?
 
henke anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say i have a button. When i click on it the first if-statment will run, the the second button click next if-statment will go and so forth. I know the Scanner class will wait for a input. Is there a way on the web?
 
Dave Tolls
Ranch Foreman
Posts: 3001
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to describe what you are trying to do on the browser.
What is it you want the page to do, and what are you expecting the user to do?

Forget about servers, Java, etc...what is supposed to happen?
 
henke anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want something to happend behind the webpage the backend. I have only one button to click on. When i click on it the first if-statment will run, the the second button click next if-statment will go and so forth.
But when i click on it all if statment will run. I want the same effect like the util.Scanner class on console.
It's it possible ?


 
henke anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Ajax
 
Dave Tolls
Ranch Foreman
Posts: 3001
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the scanner pointing at?

You're concentrating on the code, but I think what it is you are trying to achieve is more important.
What is this web application trying to actually do?


If you insist on sticking with the technical aspect then some other questions need answering.
For example, why do you need a Scanner?
What text is it being used on?

Is it reading from a file?

Has the browser sent some data in the request?  It doesn't sound like it as you say there is just a single button on the screen.

 
henke anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My web application is to make a xml file for the user. But some xml will have diffrent structure. Which is why my if-statment do.
I succeed to create xml files on console with diffrent structure but only with Scanner.
But now i am trying to move to web.
 
henke anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think like this then. "The web will dislpay do you want the elements?"
The button = "Yes". run the if-statment
 
Campbell Ritchie
Marshal
Posts: 56202
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What button? You haven't shown a button; you appear to be taking input from the keyboard. But that is an acceptable way to take keyboard input. You might be better off with a switch statement, however.

DT is right: decide what you are doing before you try to work out how to do it.

I suggest you try a little program which takes YES/NO from the keyboard and simply prints JA/NEJ. That will allow you to practise keyboard input, and later you can insert that as a component in a larger program.
 
Dave Tolls
Ranch Foreman
Posts: 3001
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the button click submits to the server.
Since the button represents a "yes" then you don't actually need to check the value as the user has said "yes" simply by clicking the button.

So...all your servlet needs to do is handle the work required to process the "yes" side of things.

I wouldn't even have an if statement.
I would have more than one servlet...unless you are using a framework for the web service?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!