[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

need help in jsp

Posted on 2006-07-14
17
Medium Priority
?
229 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 1400 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

834 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