JSP and Vector

K

KevinRobinson

Hi,

Hope someone can help.

I am using a Vector in a Servlet to return HTML to a JSP.
The problem is that the HTML rows returned to the JSP include comma
delimiters and the whole of the HTML code
is contained in square brackets.

The delimiters and brackets are visible in the JSP.

How can I get rid of the delimiters and brackets or render them not visible?

I have tried including <!-- --> but this doesn't work.

Any ideas.

Thanks in anticipation.

Kevin
 
B

Boaz.Jan

Hi,

Hope someone can help.

I am using a Vector in a Servlet to return HTML to a JSP.
The problem is that the HTML rows returned to the JSP include comma
delimiters and the whole of the HTML code
is contained in square brackets.

The delimiters and brackets are visible in the JSP.

How can I get rid of the delimiters and brackets or render them not visible?

I have tried including <!-- --> but this doesn't work.

Any ideas.

Thanks in anticipation.

Kevin

can you show us your code or be more specific? how execly do you use a
vector for this perphes?
 
B

Boaz.Jan

can you show us your code or be more specific? how execly do you use a
vector for this perphes?- Hide quoted text -

- Show quoted text -

thats because the <%=pap%> automaticlly calls the Vector.tostring()
method so it can be placed on the jsp
and the Vector.tostring() method flushes the text with those
delimters...
so you have 2 options
1) extend Vector and overide his tostring() method
2) dont use a vector. you dont need it to add dynamic content to your
JSP... if you insist on doing it this way (and i cant see any reason
why to...) user StringBuffer to create the string HTML code and the do
the <%=pap%> while "pap" is of type stringbuffer - the
stringbuffer.tostring() returns a clean string and dont have the
overhead of using a collection
secondly, why cant you do the test if to show these HTML lines at the
jsp as so:


<% if (||your condition here||) { %>
<form action=\"https://www.paypal.com/uk/cgi-bin/webscr\" method=
\"post\">
<input type=\"hidden\" name=\"cmd\" value=\"_cart\">
<input type=\"hidden\" name=\"upload\"value=\"1\">
<% } else { %>
some other html code
<% } %>

the simplest way to do it...

and if i missunderstood you and you only wanted to make a common
object to generate this line... you can use the
RequestDispatcher.include() method

for more explantions about it goto
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html#include
and
http://java.sun.com/javaee/5/docs/tutorial/doc/Servlets9.html#wp64684

hope i helped :)
 
L

Lew

can you show us your code or be more specific? how execly do you use a
vector for this perphes?

And why?

It is pretty pathological to pass HTML around as objects between servlets and
JSPs. JSPs in the first place are designed for dynamic HTML generation.

One of the most reliable design patterns for Web apps is the
model-view-controller (MVC) architecture. There is a servlet that provides
initial request parsing and dispatch to the model, or business logic, layer,
then forwards the request to a JSP for display of the results. The JSP handles
all aspects of HTML generation, but relies on the model layer to provide the
data backing the view.

I would suggest using ArrayList in lieu of Vector, but for that you should use
neither for this purpose.

-Lew
 
L

Lew

KevinRobinson said:
Hi,

Hope someone can help.

I am using a Vector in a Servlet to return HTML to a JSP.
The problem is that the HTML rows returned to the JSP include comma
delimiters and the whole of the HTML code
is contained in square brackets.

The delimiters and brackets are visible in the JSP.

How can I get rid of the delimiters and brackets or render them not visible?

I have tried including <!-- --> but this doesn't work.

Any ideas.

Thanks in anticipation.

Kevin

Your question got answers on the clj.programmer multipost.

(Cross-posted to clj.misc and clj.programmer, followup to clj.programmer.)

- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

JSP, Servlets 9
JSP Web-Development [newbie] 32
jsp include 9
javaBeans and JSP 2
JSP include and servlet 1
jsp and usebeans 1
JSP VS PHP 4
dynamically include HTML in JSP 1

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top