Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how is jsp?

Status
Not open for further replies.

wduty

Programmer
Jun 24, 2000
271
US
I work mostly with asp but I am looking into doing some java development for future projects. I have written a number of basic servlets and found the whole java thing pretty nice to work with (except for replacing existing servlets).<br><br>I am curious about jsp because examples I've seen look like asp except that the &quot;objects&quot; are actually java which I assume you can write yourself. So it's sounds sort of like COM without the hassles of dealing with C++ or VB. I this at all accurate as an assessment? Please, comments.<br><br>Since a servlet has to be generated first then compiled (at least that's how I understood it) is jsp slower than working with straight servlets? <br><br>Has anyone experienced any serious downsides to jsp? Any warnings? <p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br>
 
Dear Will,<br><br>&gt; Since a servlet has to be generated first then compiled (at least that's how I understood it) is jsp slower than working with straight servlets? <br><br>No the jsp engine compiles all files into servlet byte code files, then this is how they are executed. The engine uses the file date and time stamps to know when the jsp files need to be re-compiled into servlet byte code.<br><br>There is one catch, at least using the Java Web Server, the jsp engine only catches the outer most file. I mean if home.jsp inclues a.jsp and b.asp and you modify a.jsp the engine will not see that re-compilation is required. You must also modify the outer file (home.jsp) to get the engine to recompile the files.<br><br>&gt; Has anyone experienced any serious downsides to jsp?<br><br>No, jsp itself is great, now how does the all the rest of the technology that you must use since you are not in the ASP IIS environment stack up? There is the real meat of this issue.<br><br>Those that have been used to microsoft development environments will be in for a shock. If you were not weaned on the 4GL drag and drop development environments you should not have a problem once you get the jang of java compiler/classpath issues.<br><br>&gt; look like asp except that the &quot;objects&quot; are actually java which I assume you can write yourself. <br><br>Exactly correct! In JSP you can decide when you want binary components or script components. You can compile a java class into it's byte code .class file and place that where the web servers environment can find it and you have a binary component that can be created and used in your jsp code. You can also code(define) classes in jsp files!<br><br>// file name: inc_foo.jsp<br>&lt;%!<br>public class foo{<br>&nbsp;&nbsp;public foo(){}<br>&nbsp;&nbsp;public String getHello(){ return new String(&quot;Hello&quot;); }<br>}<br>%&gt;<br><br>// in another jsp file<br>&lt;%@ include file=&quot;inc_foo.jsp&quot; %&gt;<br>// now import a class from a class file named 'myclass.class' that belongs to a package 'mypackage'<br>&lt;%@ import class=&quot;mypackage.*&quot; %&gt;<br><br>&lt;% // script block using java since this is jsp<br>String mystr = new String(&quot;MyString.&quot;);<br>foo myfoo = new foo();<br>mystr += myfoo.getHello();<br>mystr += &quot;.&quot;;<br>myclass oclass = new myclass();<br>mystr += oclass.getHello();<br>%&gt;<br>&lt;script language=javascript&gt;<br>&lt;!--<br>function showmsg(){<br>&nbsp;&nbsp;alert(&quot;&lt;%=mystr%&gt;&quot;);<br>}<br>//--&gt;<br>&lt;/script&gt;<br>&lt;body onload=&quot;showmsg()&quot;&gt;<br>&lt;/body&gt;<br><br>Hope this helps<br>-pete
 
Wow that was fast and thorough!<br><br>Actually, since I posted this earlier today, I've been translating an old cold-fusion ecommerce site I wrote into java servlets. I'm basically replacing the old CF sections with servlet includes. It's working a-ok (java is very nice to work with I must say). At least for this site which doesn't have dynamic content woven through the whole page but only in very specific places, it seems quite possible to do the whole site using servlets with ssi. I can see where the jsp approach would be better if I had a lot of scattered content all over the place. Besides that is there any other reason why this approach would not be advisable? Beans would handle state and user issues better maybe or be more economical?<br><br>As for the classpath, and manual compilation issues, no problem - I've written enough java that I'm totally used to the slower pace and the difference from the padded environment of asp.<br><br>Another question: I'm using Java Web Server 2.0 which I downloaded from sun (for the umpteenth time) to run this stuff locally. I've also heard of people using Jrun. Is this correct? What are the differences? What other server implementations are there for running java/jsp/servlets? <p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br>
 
I don't know all of them but yeah JRun is a jsp engine that plugs into Apache. Not sure about what platforms it's available on nor how well it works. JWS is the only JSP server I've worked with. It's not recommended for high volume production sites, so you should probably start looking into JRun and any other commercial products that are available if you need 'high volume commercial use'.<br><br>Good luck<br>-pete<br>
 
wduty: You can also look into Tomcat at:<br><A HREF=" TARGET="_new"> course there are many application servers utilizing JSP (BEA, Silverstream), a free one (if you are noncommercial) is Orion at:<br><A HREF=" TARGET="_new"> BEA/Silverstream/Orion application servers, however, have additional tags/framework. <br><br>I use Tomcat, it is straight JSP and runs great.&nbsp;&nbsp;I think Sun will emphasize Tomcat over JWS (Sun pretty much did Tomcat).
 
&gt; I think Sun will emphasize Tomcat over JWS (Sun pretty much did Tomcat). <br><br>ummm... Tomcat is JWS, it's the next version(s) having been turned over to the open source group established to continue on with the Java Web Server.<br><br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top