Solved

need help in jsp

Posted on 2006-07-14
17
210 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
loop through list of objects 14 186
maven scope 1 120
library class in java 1 89
servlet concurrency 13 85
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now