JSP-Demos available online

2000-07-11 Thread Volker Turau

Hi,

the examples from my book "Java Server Pages" are now available
online in two languages: German and English (Adjust your browser
settings!). The source code can viewed online and is available for
download. Topics covered:

-- JSP scripts
-- JSP standard actions
-- Integration of beans
-- User defined taglibs
-- I18n
-- Database access
-- Shopping cart systems

The URL is:

http://shannon.informatik.fh-wiesbaden.de/buch/index.jsp


volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
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



Book Announcement: Java Server Pages

2000-05-22 Thread Volker Turau

Book Announcement: Java Server Pages

Now available:

Java Server Pages
By Volker Turau
Publisher: dpunkt ix Edition
380 Pages
ISBN 3-932588-66-5

This book provides a comprehensive in-depth treatement of
web-publishing with Java Server Pages Version 1.1. It includes
numerous pre-tested examples that you can use as the basis for your
own JSP applications. The examples have been tested with the Tomcat
and the Orion Server on Linux and Windwos NT. They are available
online (including the complete source code). The book explains the
life cycle of a JSP page and how the technology relates to servlets
and to J2EE.

What's inside:
-- internationalized applications
-- shopping cart
-- session management
-- bean based applications
-- accessing databases
-- JSP tag libraries
-- JSP V 1.1 and Servlet V 2.2 API

The book is written in German. The web-site for the book

http://www.informatik.fh-wiesbaden.de/~turau/jsp/index.html

has
-- a complete outline of the book
-- all examples online
-- all examples as a WAR file
-- two chapters as PDF file
-- lots of usefull links to JSP resources

prof. volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
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



Re: GZIPing the data to the browser

2000-04-27 Thread Volker Turau

Hi,

this example is from my forthcoming book on Java Server Pages
and has been test with Tomcat 3.1 and IE 4.0. Do not leave a blank
between %> and <%

<%@ page errorPage="/util/errorpge.jsp"
 import="java.util.zip.*"
 session="false"%><%
response.setHeader("Content-Encoding", "gzip");

GZIPOutputStream o = new GZIPOutputStream(response.getOutputStream());
String a = "GZIP ist Klasse und schnell aber .";
o.write(a.getBytes());
o.flush();
o.close();
%>

volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
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



New implicit objects in tags

2000-01-05 Thread Volker Turau

Hi,

As described in section 5.8.1 of the spec new objects (i.e. scripting
variables) can be introduced though user defined tags.

Question:

These objects seem to have scope page, you can have NESTED, etc.  but you
do not have the same scoping as for Java Beans (i.e. session, application
etc.).

Is that true? I could insert an implicit object with
   public abstract void setAttribute(java.lang.String name,
  java.lang.Object o,
  int scope)
into the scope I want to, but is this the correct way of doing this?

volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Accessing config parameters in jspInit()

1999-12-16 Thread Volker Turau

Hi,

I would like to use some configuration parameters in a JSP-page. These
parameters can be accessed through the application and config object:

application.getInitParameter(String),
config.getInitParameter(String)).

I would like to do this only once in the method
jspInit(). Unfortunately in this method these objects are not
available.

Is this a design flaw or am I missing something?


volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Re: How to compress JSP pages using Content Encoding

1999-12-06 Thread Volker Turau

You can do content encoding in jsp, I did it. Just make sure that the page
does not access the implicit variable out at all (e.g do not have blanks
outside scripts).

But I think that jsp is not the right tool to do that. The JSP-Container
should do that for you.

The code is roughly:

<%@page .><%
response.setHeader("Content-Encoding", "gzip");
GZIPOutputStream gos = new
GZIPOutputStream(response.getOutputStream());
byte[] b = " bla bla ...".getBytes();
gos.write(b);
gos.close();
%>

volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Re: Comments on answers to six questions on Tag Extensions (PR2)

1999-11-20 Thread Volker Turau

See follow-ups intermixed indicated by >>>>

| Somehow user defined tags are not discussed on this list.

I think it is just lack of an implementation.

>>> That might be the case, the orion application server supports JSP 1.1
>>> On the other hand, I think this is one of the outstanding features
>>> of JSP and I strongly believe we will see a lot of taglibs in the
>>> future.

| 1. What is the return value of the methods doStartTag(), doEndTag()
|respectively doAfterBody() in the support classes TagSupport and
|BodyTagSupport?

Note that I had mentioned SKIP_BODY, not SKIP_PAGE.

>>>> That's true, sorry my fault :-(

| 2. How do the implementations of doEndTag() differ in the classes
|TagSupport and BodyTagSupport?
|

I think you misunderstood my answer.  BodyTagSupports overrides both.
doStartTag() changes value, while doEndTag() just uses its super, so
it has the same value.

>>>> Yes a misunderstanding, you should update the current javadoc
>>>> documentation, because in the doc of the class BodyTagSupport under
>>>> the method doAfterBody() it says
>>>>  "Overrides: doEndTag in class TagSupport"
>>>> But the method doStartTag() is only listed under inherited from
>>>> TagSupport.

| 5. What happend to the method public PageContext getPageContext() in
|class Tag? Why was it deleted?
|

Maybe a class going and playing with the page context of another
class?

Let me turn it around.  Do you have a specific example for wanting
this information?

>>>> No, I was just curious. It is fine for me. Usually I try to access
>>>> all information through methods.

Thanks a lot for your comments!!!
vt

volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Six questions on Tag Extensions (PR2)

1999-11-13 Thread Volker Turau

1. What is the return value of the methods doStartTag(), doEndTag()
   respectively doAfterBody() in the support classes TagSupport and
   BodyTagSupport?
2. How do the implementations of doEndTag() differ in the classes
   TagSupport and BodyTagSupport?
3. Is it possible to use the method getPreviousOut() of class
   BodyTagSupport in the implementation of the methods doStartTag() or
   doEndTag() in subclasses of BodyTagSupport? Or can these methods
   only use pageContext.getOut()?
4. Why does the method doInitBody() in class BodyTagSupport not
   include the clause throws JspError?
5. What happend to the method public PageContext getPageContext() in
   class Tag? Why was it deleted?
6. What happened to the method public java.lang.String getTagName() in
   class Tag? Why was it deleted?


volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Exceptions in jspInit()

1999-09-18 Thread Volker Turau

Hi,

I found it awkward to catch all exceptions in the method
jspInit(). Why does this method not declare that it may throw a
ServletException, just as the method init()?


volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Scope of implicit objects

1999-09-15 Thread Volker Turau

Hi,

According to section 2.8 of the spec version 1.1 PR implicit objects
have different scopes, e.g. request has request scope and session has
session scope. But when I test this with jswdk-1.0 I get a different
result, all implicit objects have scope page. Any ideas?

I used the following simple JSP-page to determine the scope


<%@ page  import="java.util.*" session="true"%>
Implicit Objects in JSP

<% pageContext.removeAttribute("javax.servlet.jsp.jspApplication"); %>
<%!
  String table(int scope, PageContext pageContext) {
 Enumeration e = pageContext.getAttributeNamesInScope(scope);
 if (e == null || !e.hasMoreElements()) return "No Objects";
 StringBuffer result = new StringBuffer();
 result.append("");
 result.append("AttributClassSuperclass
   Interfaces");
 for (;e.hasMoreElements(); ) {
String attName = (String) e.nextElement();
Object attValue = pageContext.getAttribute(attName, scope);
if (attValue != null) {
  Class cl = attValue.getClass();
  Class superCl = cl.getSuperclass();
  Class[] interfaces = cl.getInterfaces();
  result.append("" + attName + "" + cl.getName()
  + "" + superCl.getName() + "");
  if (interfaces.length == 0)
result.append(" ");
  else {
for (int i = 0; i < interfaces.length-1; i++)
  result.append(interfaces[i].getName() + ", ");
result.append(interfaces[interfaces.length-1].getName());
  }
}
else
  result.append(""+attName+"no value ");
result.append("");
 }
 result.append("");
 return result.toString();
  }
%>

<%--<%@ include file="counter.jsp" %> <%= " 5%\\>x"  %> --%>
Request Scope 
<%= table(javax.servlet.jsp.PageContext.REQUEST_SCOPE, pageContext)%>

Page Scope 
<%= table(javax.servlet.jsp.PageContext.PAGE_SCOPE, pageContext)%>

Session Scope 
<%= table(javax.servlet.jsp.PageContext.SESSION_SCOPE, pageContext)%>

Application Scope 
<%= table(javax.servlet.jsp.PageContext.APPLICATION_SCOPE, pageContext)%>




volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Error in JSP Spec. 1.1 PR

1999-09-14 Thread Volker Turau

Hi,

section 7.4.1 of the JSP Spec. 1.1 PR defines the XML element type
jsp:declaration as



This may not be possible in all cases. Consider

<%! boolean b = f[g[6]]>4; %>

where f and g are arrays defined earlier. This gets translated into

 4;]]> 
^^^
  ERROR!!

An ugly solution is to split the declaration into two CDATA sections:



Scriplets and expressions have the same problem.



volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Thoughts on the usage of Java Beans in JSP

1999-09-13 Thread Volker Turau

Hi,

I have implemented some of the components available in Microsofts ASP as
Java Beans and used these components in JSP. In doing so I found that the
Bean concept in JSP has severe limits. I would like to hear your opinions
about my thoughts:

1. Using only the three actions useBean, setProperty and getProperty
does not allow really interesting beans. Very often I wanted to invoke
a method having parameters and printing the result. Printing is only
possible using getProperty which does not accept parameters.  It would
be usefull, if this action would accept additional parameters, for
example


   


This action should be translated into:
out.print(name.getPName(44))

Currently you have to do
<%= name.getPName(44) %>

Using this script kills one of the main advantages of beans in JSP:
simple usage. If I have to use Scripts, I might as well not use
getProperty and setProperty at all. But then the only thing left about
beans is the notion of scope (i.e. share beans in different
JSP-pages).

The current versions of setProperty and getProperty encourage
programmers to write access methods performing all kinds of
side-effects. In doing so, some actions have to be called before
others. How can you express this information to a future user of your
bean?

2. Beans should have access to implicit objects such as request,
response etc. Currently you have to use scripts again, for example

<% name.processRequest(request, session) %>

(almost all of my beans needed a similar method). It would be better
if these objects would be automatically accessible to beans. How to do
that?  Using introspection a JSP-server could detect methods such as
setRequest, setResponse etc. and invoke these method automatically
while processing the action useBean.

3. In order to assign the value of a property to a scripting variable,
you cannot do something like:

<% int i = %> 

The following works:

<% int i = name.getPName(); %>

I thought scripts should only be the "glue" between beans. Scripts
should be simple, i.e. JavaScript type. The fact that you can access a
property in two ways (<%= name.getPName() %> and ) is confusing for a non programmer.

SUMMARY:

--- Without using scripts (i.e. java code in JSP pages) beans are only of
very limited value.
--- JSP developers of type "Designer" should be able to use
Beans provided by JSP developers of type "Programmer" WITHOUT using
scripts.
--- Java code in JSP pages should be minimal, otherwise it is better
to write a servelt in the first place.
--- Java is too complex for a scripting language.



volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Re: XSL and Servlets?

1999-09-11 Thread Volker Turau

Hi,
if you want to have an online demo (including source code) of servlets
using the lotus xsl processor check out:

http://www.informatik.fh-wiesbaden.de/~turau/DB2XML/demo/db2xmlxslservlet.html


volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Re: jsp:setProperty

1999-09-07 Thread Volker Turau

> 
>  
> 
> in my bean i've got a method called "public void setPs(String [] sql)"

You need another public method called setPs(int i, String[] s) (in
addition to the first). Then you can do


sql must be of type String.
You cannot assign complete arrays (as far as I know).

volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Re: question about beanName in jsp:useBean

1999-08-11 Thread Volker Turau

Using beanName in jsp:useBean does not work with jswdk-1.0-ea, at least
not in my applications. Any other experience?

volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



Serialized Beans in JSP

1999-08-10 Thread Volker Turau

Hi,

I tried to use a Bean in its serialized form. I wrote a class
book.SerBean which I serialized into a file called color.ser which I
placed in the directory beans\book (the same directory as
SerBean.class). Then I used the following JSP page


Value of color: 

This did not work (NullPointerException). I checked the generated Java
file, this did not use the value of the attribute "beanName" at
all. Is this not supported in jswdk-1.0-ea?

vt


volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



Comments on answers to six questions on Tag Extensions (PR2)

1999-01-16 Thread Volker Turau

Hi,

here are some comments to the answers of Eduardo Pelegri-Llopart. Somehow
user defined tags are not discussed on this list.


1. What is the return value of the methods doStartTag(), doEndTag()
   respectively doAfterBody() in the support classes TagSupport and
   BodyTagSupport?

   The values you mention in your mail are not documented. The orion
   application server behaves as follows:
   TagSupport:
 doStartTag()  returns EVAL_BODY_INCLUDE (and not SKIP_PAGE)
 doEndTag()returns EVAL_PAGE

2. How do the implementations of doEndTag() differ in the classes
   TagSupport and BodyTagSupport?

   It seems odd that BodyTagSupport overrides doEndTag but does not
   override doStartTag. Since these classes will be subclassed by
   users, overriding doEndTag() by super.doEndTag() is even more odd.

3. Is it possible to use the method getPreviousOut() of class
   BodyTagSupport in the implementation of the methods doStartTag() or
   doEndTag() in subclasses of BodyTagSupport? Or can these methods
   only use pageContext.getOut()?

   Using getPreviousOut() seems logical. Appartently the orion server
   reports an error when doing so.

4. Why does the method doInitBody() in class BodyTagSupport not
   include the clause throws JspError?

   Bug in PR2, ok

5. What happend to the method public PageContext getPageContext() in
   class Tag? Why was it deleted?

   Providing pageContext as a protected field doesn't seem to be
   consistent with the other J2EE APIs. There only very few protected
   fields in these classes. Why did you choose pageContext as one of
   them? Why is it safer?

6. What happened to the method public java.lang.String getTagName() in
   class Tag? Why was it deleted?

   I used it only for error reporting (as you mentioned). I found it
   usefull, because introducing the tag name in the tag handler class
   makes it harder to change tag names (it is redundant). Also if you
   subclass tag handlers error reporting using getTagName() was easy.


Thanks for answering my questions! :-)




volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html



Comments on the SQL Tags and example source code (PR2)

1999-01-16 Thread Volker Turau

Hi,

I tested the example source code for the SQL tags using the orion
application server. I am aware the stuff is only included for
pedagogical reasons. I found it usefull to experiment with the code.

There are a few things I had to change:

-- ConnectionTag and QueryTag are using DefaultTEI as their teiclass.
   This is not possible, because the class names of the variables
   cannot be String (as in DefaultTEI). They must be
   java.sql.Connection respectively java.sql.ResultSet. This raises
   the question if the concept of TagExtraInfo classes is really so
   useful. The classes ConnectionTEI and QueryTEI I had to introduce
   are almost identical.

-- The constructor of ConnectionTag needs to load a JDBC driver.

-- There is an inconsistency between the PR2 documentation and the
   sample source code:
   On page 133 the tag  has an attribut iterate with value
   row. In the source code the attribute's name is row. Also on this
   page the methods getAccount() and getBalance() have to be changed
   to getString(1) or something similar.

-- I could not use the query
select OrderDate from orders where ORDERID < 11061
   because of the character < in the query. Any ideas how to protect
   these characters?

After changing this minor details the examples worked. Has anybody
comments or experience with these tags or designed different db tags?



volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html