File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Cattle Drive and the fly likes On the brink of madness Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "On the brink of madness" Watch "On the brink of madness" New topic

On the brink of madness

David Mason
Ranch Hand

Joined: Jan 21, 2002
Posts: 56

Really I am.
And it's Servlets-4b that's doing it.
I appear to need to have constant strings of html with variable bits in them.
You see I really am mad.
Initially each servlet had it's own string of html and much was the same between servlets, eg .html..head..title.Assignment 4.4b - Add a Video ./title../head. ...
It was suggested that I try to share html fragments as widely as possible. So I did. I extracted the common stuff and put it somewhere common; there were short strings, and very short strings. I created methods to access the common bits and insert the variable stuff.
Now it is suggested that I have constant strings and just print them.
But I don't see how to insert the variable stuff into the constant strings.
Please help. I think I'm going mad.
I'm certainly , & .
And I'm getting to be certifiably
John Hembree
hired gun
Ranch Hand

Joined: Mar 07, 2003
Posts: 250

First the disclaimer, I'm normally way off when it comes to the nitpicker's choice of really cool features to implement.
I would think that a constant can't have a variable in it, that would make it dynamic, so break your strings up around the variable.
If the title is dynamic, have a constant title start and a constant title end, then wrap your title variable with these new constants. Do this all the way thru your code and send it in, which per my disclaimer means you'll be getting it back to redo it.
David Mason
Ranch Hand

Joined: Jan 21, 2002
Posts: 56

Thanks John.
That's what I tried to do - the "doHeader" method takes the variable parameter and wraps the constant "headerHead" and "headerTail" strings around it.
And yes, it did come back for rework; I've got too many doXXX routines
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I think you have to print a little "constant" stuff, print a bit of "variable" stuff, then a bit of "constant" stuff, and so on...
(I didn't do it that way at first of course.
I was also lacking in the mutant parrots area)

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
David Mason
Ranch Hand

Joined: Jan 21, 2002
Posts: 56

Ta Barry,
Ain't it amazing how difficult it is to see the path, when your nose is up against a tree
I agree. Here's the link:
subject: On the brink of madness
It's not a secret anymore!