Solved

need help in jsp

Posted on 2006-07-14
17
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Make the most of your online learning experience.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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