27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

General <strong>Java</strong> Questions I<br />

The JSP/Servlet model is more geared toward distributed n-tier applications where<br />

there is at least logical, and possibly physical, separation of model, view, and<br />

controller functions. It is more complex than PHP, but also more scalable, and<br />

well-written <strong>Java</strong> apps may be a great deal more maintainable because of the<br />

separation of logical tiers.<br />

They're both nice tools, and I use both, but I don't think either one is going to kill the<br />

other anytime soon.<br />

--<br />

Joe<br />

Q: My question is : is JSP as powerful as servlet?<br />

I heard that JSP will eventually compile into servlet class file.<br />

One thing can be done by servlet, can it be done by JSP too? In terms of http.<br />

Answer: Everything a servlet does can be done in JSP and vice versa. Good<br />

programming practice (you will see some articles over the last year in <strong>Java</strong>Pro)<br />

dictates to combine servlets and JSP in any significant web application.<br />

JSP should be mainly HTML (or XML, or WML or whateverML) with little <strong>Java</strong> inside.<br />

Servlets should be <strong>Java</strong> with few or not at all lines like this:<br />

out.println( "" );<br />

out.printlb( "" );<br />

This creates a more or less clean separation between presentation (JSP) and<br />

business logic (servlet).<br />

<strong>Java</strong> beans also have a role in this. I strongly recommend the <strong>Java</strong>Pro articles or<br />

whatever text on the MVC model you can find.<br />

-eugene<br />

aresteanu<br />

Q: I'm just starting to learn <strong>Java</strong> on my own. Should I first learn AWT or should I<br />

jump directly into the Swing of things?<br />

Answer: Will you be wanting to code applets that are easy for anyone to run in their<br />

browser? If so, you'll probably have to go with the AWT for now.<br />

The AWT isn't so bad, but Swing makes a lot of things much easier, so if you want to<br />

ship native-code applications or suchlike then I'd go with Swing. I still use the AWT,<br />

but I find myself having to code a lot of 'standard' things myself.<br />

--<br />

Mark<br />

Swing make things easier but IE doesn't support it.<br />

Q: I can't manipulate inodes on my linux box ... in fact I can't even get real info<br />

about a file! <strong>Java</strong> is a bad hack and is for kids who aren't sharp enough to do C++.<br />

Answer: Think of <strong>Java</strong> in the same terms as COBOL and VB, and you've got the right<br />

idea. Start thinking of it as a replacement for C++ and you're on the wrong track.<br />

Don't expect this portable language to be a tool for low-level coding with hooks into<br />

the OS and hardware internals. It just wasn't designed for that. It's an excellent<br />

*applications* language, not a *systems* language like C or assembler.<br />

On the other hand, if any pesky <strong>Java</strong> programmers tell you that C++ is dead and that<br />

<strong>Java</strong> can do everything C++ does, and more, you may howl with laugher and tell<br />

them to eat their JVM.<br />

file:///F|/350_t/350_tips/general_java-I.htm (3 of 31) [2002-02-27 21:18:17]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!