-----Original Message-----
From: Pang Zhenqi [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 18, 2000 5:42 AM
To: [EMAIL PROTECTED]
Subject: How to use Jsp and Servlet together?


Hi all,

Although I have written a few Jsp/Servlet code, I'm still confused about
some basics, General method to use Jsp and Servlet together is:
In Jsp, submit to Servlet, then Servlet get data with Bean, then forward to
Jsp.
I think there are several drawbacks using this method.
1. Render all data with Jsp looks rather chaos. e.g.
    In Jsp, there is a table whose data is retrieved from DB, the code
combined Java code with HTML is hard to read, why not manipulate the HTML
code in Servlet,then in Jsp:
    Set necessary attributes, request.setAttribute("", "");
    <jsp:include "/servlets/DisplayDataServet">, very neat. using this
method, we can write some frequently-used servlet, such as :<Page Up, 1, 2,
3 Page Down>

=> This is what custom tags are for.


2. After forward to Jsp, the URL still display Servlet url, the most
important, in Jsp file, we must use absolute file path(image), it's very
inconvenient for HTML designer. how to solve it?

=> Well ... the url display is handled by the client, and the forward is all
done
=> server-side as far as I know (i.e. the client doesn't get to know about
it, and
=> therefore can't update it's url display). The client requests any images
in the
=> html response separately and (I think ...:>) uses the url it knows (i.e.
the
=> one in the url display) as the basepath for relative image urls.

=> Though I haven't tried it, I would expect that as long as the relative
path from
=> the page you forwarded to for an image is the same as the relative path
for that
=> image from the controlling servlet or whatever, it might work.

3. In jsp file, if I use bean(through usebean tag) always get
ClassCastException. I know the reason, but it still make me unhappy.

=> I've never seen this exception when using usebean (though I have in
methods in
=> beans put into scope with usetag). I guess it's an implementation error
in
=> the class you are using.

I like to use the cutting-edge technology and the most decent method, but in
Jsp/Servlet, I never use any common method, I feel very frustrated.

=> I've been using jsp for 4 months, so I'm still a newbie at it I think.
It's taken
=> probably 75% of that time for me to really understand how to write an
application
=> using a (reasonably) unified approach. I still haven't taken things as
far as
=> I could though (for example, I've never used custom tags, though I know
they exist
=> and sort-of what they can do). I also keep intending to look at struts to
see how
=> that can help support (very well from what I've heard) a Model 2
architecture.
=> Maybe this would help your development too.

Any suggestion or clue are highly appreciated.

Pang

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to