You will definitely have to describe what you are trying to do more clearly. Otherwise, the only answer I can give is not put HTML tags that you don't want there in the first place!
Are you talking about conditionally not including them based upon some server-side condition? Some client-side activity? If the earth starts revolving in the other direction? Other?
Its server condition. Basically, the will get the HTML text from the DB and a small snippet of each record will be displayed to the user in the JSP without any HTML formatting so that the text doesn't messup the layout or take more space than it should it. I did initially do the stripping on serverside using regex but it became a problem because of the different types of data that can be retrieved from the DB I had to introduce 4 different Maps (mapping resultset to new object) and its taking up around 100+ lines of code. So instead I have decided to stick to just one object map and do the stripping in the JSP instead.
So you have an HTML fragment of text from which you want to strip HTML tags? That's something you'll have to do with something other than JSTL.
Personally, I'd make the changes earlier such that HTML isn't stored in the DB in the first place. But if that's not possible I'd certainly make sure to cleanse the stringprior to forwarding it to the JSP.
I've moved this to a general Java forum with an appropriate change in title as this is not JSP-specific.
shaf maff
Ranch Hand
Joined: Sep 07, 2008
Posts: 180
posted
0
Well, if I use this method I can remove around 60 or so lines of code. I know how to remove html from strings, I just wanted to know if its possible in JSPs usings JSTL.
I suppose using the string manipulation functions of the JSTL fn function you might be able to figure out a way do it, but ti'd be messy and cumbersome and something not at all suited to doing in a JSP page. Cleanse the string perior to sending to the JSP in the first place.
I am not sure, but as you're hammering on using JSTL, I guess that you actually meant "escape" instead of "remove". If this is true, you can just use JSTL's c:out for that.