Solved

need help in jsp

Posted on 2006-07-14
17
217 Views
Last Modified: 2010-04-01

Currently it prints like this

--------------------------------------------------------------------------------------------------------------
The Final Marathon                                                                        07/05/2006 to 07/31/2006
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis malesuada semper lacus.
Integer nulla. Phasellus in sapien. Morbi cursus. Nunc at massa ut eros condimentum venenatis.
Suspendisse potenti. Nulla et sapien. Donec auctor faucibus nibh. Proin sed urn [read more]
---------------------------------------------------------------------------------------------------------------
But I need it like this and also hlso how can I make read more a link
--------------------------------------------------------------------------------------------------------------
The Final Marathon                                                                        07/05/2006 to 07/31/2006
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis malesuada semper lacus.
  Integer nulla. Phasellus in sapien. Morbi cursus. Nunc at massa ut eros condimentum venenatis.
  Suspendisse potenti. Nulla et sapien. Donec auctor faucibus nibh. Proin sed urn [read more]
---------------------------------------------------------------------------------------------------------------

Thnaks

<tr width ='500'>
       <td colspan ='2'> <hr width = '500'> </td>
</tr>
                         
<tr width ='500'>
         <td>
                 <a href="<%=chapter_name%>?action=show_eventDetail&eid=<%= next_event.getEvents_ID() %>"><%= next_event.getEvent_title()%></a>
          </td>
          <td align ='right'>
                  <%= next_event.getEvent_date() %> to <%= next_event.getEvent_date_end()%>
           </td>            
 </tr>
 
<tr width ="500" >
           <td colspan ='2'>
                   <%=next_event.getDescription().length()>300?(next_event.getDescription().substring(0,300)+ " [read more]"):next_event.getDescription() %>
            </td>
 </tr>
0
Comment
Question by:huzefaq
  • 8
  • 5
  • 4
17 Comments
 

Author Comment

by:huzefaq
ID: 17111481
Also would someone know how to make the description block format

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis malesuada semper lacus.
  Integer nulla. Phasellus in sapien. Morbi cursus. Nunc at massa ut eros condimentum venenatis.
  Suspendisse potenti. Nulla et sapien. Donec auctor faucibus nibh. Proin sed urn [read more]
0
 
LVL 4

Expert Comment

by:Meritor
ID: 17113691
<tr width ="500" >
           <td colspan ='2'>
                   <BLOCKQUOTE style="margin-left: 10">
                   <%=next_event.getDescription().length()>300?(next_event.getDescription().substring(0,300)+ "<a href='yourpath'>[read more]</a>"):next_event.getDescription() %>
                    </BLOCKQUOTE>
            </td>
</tr>
=====================OR=====================================================
<tr width ="500" >
           <td colspan ='2'>
                   <P style="margin-left: 10">
                   <%=next_event.getDescription().length()>300?(next_event.getDescription().substring(0,300)+ "<a href='yourpath'>[read more]</a>"):next_event.getDescription() %>
                    </P>
            </td>
</tr>

Regards,
Hatim
0
 
LVL 4

Expert Comment

by:Meritor
ID: 17113693
You can even set margin-bottom, margin-right, and margin-top.
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 35

Expert Comment

by:TimYates
ID: 17121111
Or, a more modern way:

<div class="event">
    <div class="title">
        <a href="<%=chapter_name%>?action=show_eventDetail&eid=<%= next_event.getEvents_ID() %>"><%= next_event.getEvent_title()%></a>
    </div>
    <div class="date">
        <%= next_event.getEvent_date() %> to <%= next_event.getEvent_date_end()%>
    </div>
    <div class="body">
       <%=next_event.getDescription().length()>300?(next_event.getDescription().substring(0,300)+ " [read more]"):next_event.getDescription() %>
    </div>
</div>

Then add the following CSS to the HEAD of your page:

  <style type="text/css">
    .event {
      border: 1px solid black ;
      padding: 5px ;
      width: 500px ;
    }

    .event .title {
      width: 50% ;
      background-color: #DDDDDD ;
      float: left ;
    }

    .event .date {
      width: 50% ;
      background-color: #DDDDDD ;
      text-align: right ;
      float: right ;
    }

    .event .body {
      clear: both ;
      margin-left: 1em ;
      text-align: justify ;
    }
  </style>

Tim
0
 
LVL 4

Expert Comment

by:Meritor
ID: 17121150
<Div> tags may not work properly in some browsers.
The idea of Using CSS is good.
You can even add 'class' to  paragraph (<P class='className'>)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 17121202
they work in IE and firefox (afaik) :-/

Which browsers don't support them?
0
 
LVL 4

Expert Comment

by:Meritor
ID: 17121987
Please Visit this link for browser support
http://www.blooberry.com/indexdot/html/tagpages/d/div.htm
0
 
LVL 35

Expert Comment

by:TimYates
ID: 17122021
That seems to say it's supported by IE 3+, Netscape 4+ and Opera 3.5+

Which seems pretty comprehensive in my book ;-)

hehehe

Tim
0
 
LVL 4

Expert Comment

by:Meritor
ID: 17122531
Its ok dear!
 Our main perpose of being here is to help programers by solving their problems. And I think 'huzefaq' have got the solution.
 
 
0
 
LVL 35

Expert Comment

by:TimYates
ID: 17122565
I agree completely...  I was just pointing out that div's aren't as bad as you implied ;-)  (so we don't scare other people who find this question in the future)

Tim
0
 

Author Comment

by:huzefaq
ID: 17122683
Thanks all for all your help

TimYates, I tried using the style sheet method but I wasn't able to put a link on [read more].

I tried the fllowing code
-----------------------------------------------------------------------------------------------------

<tr><td>
                              <div class="event">
                                    <div class="title">
                                          <a href="<%=chapter_name%>?action=show_eventDetail&eid=<%= next_event.getEvents_ID() %>"><%= next_event.getEvent_title()%></a>
                                    </div>
                                    <div class="date">
                                          <%= next_event.getEvent_date() %> to <%= next_event.getEvent_date_end()%>
                                    </div>
                                    <div class="body">
                                          <%=next_event.getDescription().length()>300?(next_event.getDescription().substring(0,300)+ "<a href="<%=chapter_name%>?action=show_eventDetail&eid=<%= next_event.getEvents_ID() %>"><%= next_event.getEvent_title()%>"> [read more]</a>"):next_event.getDescription() %>
                                    </div>
                              </div>

                              <%}
                        }%>      
                        </tr></td>




-----------------------------------------------------------------------------------------------------

and it gives me this error
------------------------------------------------------------------------------------------------------
error on token "%=", delete this token

An error occurred at line: 73 in the jsp file: /templates_public/publicEvents.jsp
Generated servlet error:
Syntax error, insert ": Expression" to complete Expression

An error occurred at line: 73 in the jsp file: /templates_public/publicEvents.jsp
Generated servlet error:
Syntax error, insert ")" to complete Expression


-------------------------------------------------------------------------------------------------------
0
 
LVL 35

Expert Comment

by:TimYates
ID: 17122726
Yeah, this line:

    <%=next_event.getDescription().length()>300?(next_event.getDescription().substring(0,300)+ "<a href="<%=chapter_name%>?action=show_eventDetail&eid=<%= next_event.getEvents_ID() %>"><%= next_event.getEvent_title()%>"> [read more]</a>"):next_event.getDescription() %>

in the <div class="body"> is a bit confused...  (you've got tags opening inside tags, etc)

Change it to:

    <%= next_event.getDescription().length() > 300 ? next_event.getDescription().substring( 0, 300 ) + "<a href=\"" + chapter_name + "?action=show_eventDetail&eid=" + next_event.getEvents_ID() + "\">[read more]</a>" : next_event.getDescription() %>

And it should work...
0
 

Author Comment

by:huzefaq
ID: 17122740

Please ignore my previous reply.

TimYates, I tried using the style sheet method but I wasn't able to put a link on [read more].

I tried the fllowing code
-----------------------------------------------------------------------------------------------------

<tr><td>
                              <div class="event">
                                    <div class="title">
                                          <a href="<%=chapter_name%>?action=show_eventDetail&eid=<%= next_event.getEvents_ID() %>"><%= next_event.getEvent_title()%></a>
                                    </div>
                                    <div class="date">
                                          <%= next_event.getEvent_date() %> to <%= next_event.getEvent_date_end()%>
                                    </div>
                                    <div class="body">
                                          <%=next_event.getDescription().length()>300?(next_event.getDescription().substring(0,300)+ "<a href='<%=chapter_name%>?action=show_eventDetail&eid=<%= next_event.getEvents_ID() %>'> [read more]</a>"):next_event.getDescription() %>
                                    </div>
                              </div>

                              <%}
                        }%>      
                        </tr></td>




-----------------------------------------------------------------------------------------------------

and it gives me this error
------------------------------------------------------------------------------------------------------
 Unable to compile class for JSP

An error occurred at line: 73 in the jsp file: /templates_public/publicEvents.jsp
Generated servlet error:
String literal is not properly closed by a double-quote




-------------------------------------------------------------------------------------------------------
0
 
LVL 35

Accepted Solution

by:
TimYates earned 350 total points
ID: 17122747
See my previous post :-)

http:Q_21919992.html#17122726
0
 

Author Comment

by:huzefaq
ID: 17122826
it works, thanks

one more thing, I was trying to change the color of the bar to something in blue. Now is there a website where it shows the color and list the number of the colors, so I can easily change and check the results

Thanks again
0
 
LVL 35

Expert Comment

by:TimYates
ID: 17122902
Glad it's solved huzefaq! I really think a split would have been fairer here, as Meritors solution was valid as well... :-/

As for the color choosing thing, I tend to use the palette control in Gimp or Photoshop (as it shows you the HTML hex encoded color in it)...  There are things like this on the web as well:

http://www.pagetutor.com/colorpicker/index.html

Which may help :-)

Want me to ask for this question to be re-opened, so you can split the points?  Or if you want to do it, you can ask a question here http:Community_Support/ for 0 points requesting it :-)

Thanks, and good luck!

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 17122909
also, the firefox browser lets you edit CSS whilst looking at the page, which can be handy for doing these sort of "tweaks" :-)

Tim
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
unit test DAO layer 1 137
dateFashion java challenge 9 141
approach on java challenges Approach on java challenges or real world challenges 29 160
print map entry 34 69
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
As a business owner, there are many things that keep you up at night. Profit margins, employee retention, human resource protocols, whether your product or service will remain competitive. When you own or manage a technology company that operates la…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question