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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Title and Div

Status
Not open for further replies.

cohans

Programmer
Aug 21, 2001
35
US
I want to set the title and a div body content based on a querystring parameter coming into a JSP page. Can I do this? If so how? Thanks.
 
Example for setting a page title in JSP:
Code:
<html>
<head>
<title><%= request.getParameter(&quot;title&quot;) %></title>
</head>
</html>

This is assuming that the title parameter is passed as part of the url. Wushutwist
 
Thnak you very much. I was able to get figure the title out. Any takers on the <div>?
 
What you are doing in the div? Could be anything, that is why I left it out. It is all the same concept though, get the parameter and place it on the page. Wushutwist
 
I'm simply placing text in it. I've tried setting it using the div id and various attribute names for the body content, but I haven't been succefull. Here's a some xamples of what I've tried:
.
.
<div id=&quot;heading_div&quot; align=&quot;center&quot;> </div>
.
.

<script language=&quot;JavaScript&quot;>
document.forms[0].heading_div =
&quot;First attempt.&quot;
document.forms[0].heading_div.body_content =
&quot;Second attempt.&quot;
document.forms[0].heading_div.text =
&quot;Third attempt.&quot;
</script

Note: I try only one of the 3 samples at a time. I've put them all in one script tag for brevity.
 
Simple Example:
Code:
<div><%= request.getParameter(&quot;divBody&quot;) %></div>

Assuming divBody is the parameter passed. This is the simplest form of web programming. There are many many more things you can do with JSP and Servlets beyond passing everything around in Querystrings. Wushutwist
 
Not that simple. I neglected to mention that I'm trying to set this div tag at the bottom of the file, below the
div definition. I'm doing this so I can remove my jsp code from the html. The jsp code will eventually be converted to taglibs.
 
Well then you kind of lose the purpose of using JSP because then you are left to use something like Javascript. Doesn't make any sense. Taglib is essentially jsp anyways. I don't understand why you would put this kind of restraint on yourself. It is not like you are embedding huge convuluted chunks of Java code in your documents. Wushutwist
 
Right but taglibs are intended to help removing the business logic from the presentation. I will be using javascript and jsp together, but we are trying to do so outside of the html (presentation) so the our business logic is removed.
 
But you are still putting Java in your html pages... just all the way down at the bottom. So the two options you are considering are:
1) Place a tiny bit of Java code mixed in with HTML (purely for presentation purposes).
2) Place a bit more Java code mixed with a convoluted javascript at the bottom of the page to do a simple routine.

Disadvantages to 1: Mixture of Java and HTML but no Java logic to drive the page.
Disadvantages to 2: Still a mix of Java and HTML, throw in a bit of javascript and now you have a maintence nightmare.

With the exeception of Custom Tags, it seems number 1 is the only logical answer. BTW, the Custom Tag for this purpose would be trival to write and if number one is definitely out (for whatever reason) I suggest going with the Custom Tag solution.
Wushutwist
 
Thanks for your opinion. It definitely has me thinking. I see merits to both arguments. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top