Solved

need help in jsp

Posted on 2006-07-14
17
218 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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