aspose file tools*
The moose likes JSP and the fly likes Using robot class in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using robot class in jsp" Watch "Using robot class in jsp" New topic
Author

Using robot class in jsp

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Ok, here is my code.



And these are the errors I'm getting.



I understand the first and third error, but I feel I have checked my code
a lot and don't see why I'm getting them.

as for the second error, I have no idea what that is supposed to mean.

Thanks,

Justin Fox
[ January 12, 2008: Message edited by: Bear Bibeault ]

You down with OOP? Yeah you know me!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You've got a scriptlet tag nested inside another scriptlet tag.



Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
when I didn't put the tag around the out.println statement, I was getting errors still, like that was bad or something.

I don't think i can put out.println statements in <%! %> tags.

Justin Fox
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Ok, I got it working, but it executes that function before the page loads?
how do I make it to where the function only happens when the buttion is clicked...

Justin Fox
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Originally posted by Justin Fox:
how do I make it to where the function only happens when the buttion is clicked...

You don't. The Java in the JSP -- which at this stage of the game is a bad habit you should drop asap -- executes on the server long before the HTML page is sent to the browser where a user will get the opportunity to click on a button. You should read this article.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
ok, so basically all the java in the jsp is executed before the page is sent to the browser... What good is JSP besides being a server sided language more familiar to java programmers?

I mean PHP or ASP does the same thing. I was under the impression that jsp could somehow dynamically update stuff from the server-side of things.
With a page refresh though? I can do that with PHP.

I guess AJAX is the only way to update stuff client-side "dynamically".

And I got an answer that basically said using java in the jsp file was a no no? I thought jsp stood for java servlet pages...

I don't know, I don't really know all that much about jsp, besides that its a server-sided scripting language comparable to php and asp and asp.net and others.

If I could get some better explaination of jsp's pros, that would be nice.

Thanks,

Justin Fox
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Originally posted by Justin Fox:
What good is JSP besides being a server sided language more familiar to java programmers?
JSP is an extremely powerful server-side templating language with all the power of Java behind it. As the view tier of a web application written in Java, you get all the extensibility, scalability and security that the language provides.

I mean PHP or ASP does the same thing.

They're all implementations of the same idea. With JSP, you get the power of Java behind you. Not so much with php.

I can do that with PHP.

Sure, if php is more familiar and works for you, great! I personally found php to be very limiting as soon as a web app goes beyond a page or two.

I guess AJAX is the only way to update stuff client-side "dynamically".

Bingo.

And I got an answer that basically said using java in the jsp file was a no no? I thought jsp stood for java servlet pages...

It does. But just because you can do something, doesn't mean it's a good idea. With JSP 2.0, the Java-powered EL and JSTL provide a much cleaner means of creating dynamic templates than old-fashioned scriptlets.

In a Java web app (at least a well-structured one), the vast majority of the app will not be on the pages (compare that to a php app), but in robust Java classes. The JSP pages end up being just a small facet of the app used to dynamically generate the HTML pages. All the real work goes on "behind the scenes".
[ January 11, 2008: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

This article regarding web application structure might be informative.
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Thanks for the info,
I really do appreciate it. Kinda cleared things up for me

But one more thing...

In what instance or senario (in developing a website) would JSP be a better choice for the server-sided script than say PHP or ASP?


In a Java web app (at least a well-structured one), the vast majority of the app will not be on the pages (compare that to a php app),


Are you speaking of an actual Java Applet? Or are you talking about a Java "App" in JSP on the server side?

If it was referring to a Java Applet, how can you compare that to PHP is what I'm getting at.


And using AJAX with JSP would be similar right? just do the "xmlHttp.open(GET,url,true);" and then on the jsp side get the variables in the url, do some kind of calculation and then "out.println(responseText);" right?


Thanks again,

Justin Fox
[ January 12, 2008: Message edited by: Justin Fox ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

In a well structured Java web app, most of the code will be in servlets, beans, and plain old Java objects. Once the work of these classes is done context is forward to the JSP which is only responsible for marking up the response as HTML/Javascript.

We have some examples in our CodeBarn.
See SimpleMVC and SimpleCommand.

These examples (and more) can also be downloaded from my site http://simple.souther.us.

If you look the code in these examples, you'll see that there is very little going on in the JSPs.

Applets have nothing to do with any of this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using robot class in jsp