HELP PLASE ! JavaBean and Javascript in frames :)

Hello,
First please excuse me for my bad english I'm French think you in advance for your patience and your help ! :)
To resum the problem :
I have 2 frames, a menu frame and a main frame
I use a javabean wich is saved in application variable.
When the pages of main frame use the javabean there is no probleme.
BUT when menu frame calls pages of main frame it don't restore the javabean, it looks like je page called by menu frame, which operates on the javabean, wasn't called, and the changes I do in this page aren't saved
Menu frame uses javascript to calls main frame pages so I think the problem is conjonction of frame and javascript.
But I have no choice because it's volonty of my boss, so please help me ! :)
More precisly :
the javabean : NavigationBean
page frame menu : menu_page.jsp
main pages which use javabean : pageA.jsp, pageB.jsp, pageC.jsp
pageA.jsp has reference on pageB.jsp which has reference on pageC.jsp
Traitement of the javabean NavigationBean in pageA.jsp, pageB.jsp and pageC.jsp :
<jsp:useBean      id="gestionNavigation"
          class= "NavigationBean"          
          scope="application">                         
</jsp:useBean>
<jsp:setProperty      name="gestionNavigation"
               property="request"
               value="<%=request%>" />     
(it needs response and request to run)
<jsp:setProperty      name="gestionNavigation"
               property="response"
               value="<%=response%>" />
<jsp:setProperty      name="gestionNavigation"
               property="pageActuelle"
               value="<%=urlActuelle%>" />
(it saves in NavigationBean object the url where user is)
In pageA I clean all NavigationBean so all pages saved are deleted
if user go DIRECTLY on pageA.jsp, all is ok :
user go on
     pageA -> pageB -> pageC
and NavigationBean save
     pageA -> pageB -> pageC
That's good ! :)
BUT if after user go on menu frame it's wrong !
user go on
     pageA -> pageB -> pageC -> menu_page.jsp -> pageA -> pageB
BUT NavigationBean save
     pageA -> pageB -> pageC -> pageB
instead of
     pageA -> pageB
To resume, for NavigationBean when user go directly on main pages there is no problem, but when it uses menu frame it doesn't save that user go on pageA
I clean NavigationBean on pageA, but instead of this problem it doesn't clean and retrieve old datas
It looks like that when user uses menu FRAME it uses an old NavigationBean object, but when it go directly on pages of main frame it runs !
And I use scope application so don't understand, I have tried session scope but no change :(
I have tried using "response.encondeURL" but no change
Think you in advance for your help, and good luck from Paris for all New York people ! :)
David

It sounds like what might be happening is when the user goes 'back' to the menu, they're not requesting the page from the server. So, they're either getting the old page cached by the browser. Maybe. If you reload the menu page manually, does it work?

Similar Messages

  • Need help with taglib and javascript issue

    I have created two WebSphere portlets (using WebSphere Application Studio), which exchange information by using click-to-action. I have added the click-to-action functionality programatically.
    On my source portlet jsp page I took the java code which generates the click-to-action javascript and added it to a taglib I created. The problem is that now the click-to-action functionality doesn't work.
    When I look at the source code in the browser the javascript and the onClick code is there as it should be, but when I click on the hyperlink, the click-to-action menu is not displayed.
    If I take the java code out of the taglib and put it back into the jsp page it works no probs and on inspection of the generated code it is exactly the same as the code generated by the taglib version.
    I have noticed that when I click the hyperlink to fire the onClick event I get an error message in the browser but when I go to the line number given in the error message, there is no code on that line.
    Any ideas why it doesn't work when put in a taglib?
    Thanks in advance,
    A.

    There can be a million reasons
    1) What is the exact error line?
    2) Try debugging in Mozilla instead of IE. Mozilla's javascript debugger is much better. In IE you may have to look more at the error message then the line it gives you to id where the error occurs.

  • HTMLEditorKit : How you handle FRAMES, IFRAMES and JAVASCRIPT

    Hi all,
    Currently im using the HTMLEditorKit to parse through the HTML page. Obviously its easier when the elements are on the body of the page. But what if the page has frames,iframes or javascript and i want to extract links that these elements reference to. How do i do it? I know some of you would recommend my class to extend the parsercallback class. But is there a way for example i can use 3 or even 4 different iterators each pointing to the different elements ?
    and lets say if i reference to a SCRIPT tag of the HTML, how do i extract the possible URLs in it. Same goes for iFrames and JavaScripts. Can anyone please help me with this ?

    Tim,
    The form action needs to be the page URL. The INPUT fields/objects of your form will be sent as parameters when the form is submitted. These parameters can be read by your portlet by using the parameter passing PDK services. It is recommended to use qualified parameters in case the portlet that reads the parameters is the same as the one that has submitted them.
    As far as I remember the parameter passing sample portlet contains similar code to what you're looking for.

  • Okay so i had an iphone 5.  I backed it up on icloud. Then i got the new iphone 5s i restored ot from icloud from my previous iphone 5.  Now everything works find execept now the games are slowy and drops the frame rate and look choppy. Please help.

    Okay so i had an iphone 5.  I backed it up on icloud. Then i got the new iphone 5s i restored ot from icloud from my previous iphone 5.  Now everything works find execept now the games are slowy and drops the frame rate and look choppy. Then i restarted my iphone 5s as a new device downloaded the same apps even the ones optimized for ios 7 and the games still lag. And i just got my iphone 5s replace.  The funny thing is.  While im playing games and their running choppy and slow and if i take a snap shot inside the phone. They run smooth and HD but just for a few seconds and boom they go back to slow and choppy.  Is it the ios 7 or the iphone 5s it self? Like i said this is my replacement iphone 5s because the other 5s did the same thing. And it was running slowly.

    As far as I know you can't delete the primary email address for an iCloud account.  It's assigned when the account is created.  But your neighbor wouldn't have been able to get into your iCloud account without your Apple ID and password.  Are you sure the account wasn't still on your phone when you gave it to him?
    You could migrate a copy of your data to a new iCloud account but I would still be concerned that someone else was using my old account, which presumably still has your data in it.
    I'm fairly certain that you're going to have to have iCloud support help you sort this one out as they may have the ability to make changes to an existing account that users can't.  Make an appointment with the genius bar at a nearby Apple store and have them take a look at it.  If necessary, they should be able to contact iCloud support for you.

  • Accidently installed NoScript, can't get rid of it and JavaScript has been disabled even though it says it's enabled - help!

    I accidently installed NoScript when trying to remove adverts/pop-ups. Now it's causing problems on various sites I regularly use and I can't get rid of it. It doesn't show up on Tools/Add- ons so I can disable and JavaScript has been disabled, even though it shows as 'Enabled'.
    Help would be appreciated.

    The usual method for uninstalling extensions and themes is by using the Add-ons manager for your Mozilla application, as follows.
    # Click "Tools -> Add-ons
    # Click on the Extensions or Themes button on the top.
    # Click on the extension or theme you want to uninstall.
    # Click Uninstall.
    # Restart your Mozilla application.

  • When I apply smoothing to a clip, it does nothing and the video frame remains static! Please Help!

    When I apply smoothing to a clip, it does nothing and the video frame remains static. As opposed to moving around in order to compensate for my movement, which exposes black edges. That is what I am trying to get. Please help
    These are the steps I follow. Import clip > Library > Behaviours > Motion > Stabilize. I then add the stabilize > go to inspector and change method to smooth and finally, analyze. However, it is not doing anything. My Macbook Pro was recently replaced and this is what I recall doing on my previous one, but it doesnt seem to be working for me. Is there a step im missing or something?
    Thanks for any help!

    Smooth is just going to smooth out a little "jitter" or jerkiness in the footage. Unless there is a lot of camera movement, you won't notice much. If you really want to see Motion go to work, change the Method to Stabilize.
    BTW, once the footage is analyzed, you can make any changes you want to any of the other parameters - you don't have to re-analyze. I recommend Stabilize with Adjust: Position Scale and Rotation and Borders set to Zoom (depending on the quality of the video) — or you might consider adding a mask to the group the stabilized video is in

  • Frames and javaScript

    Hey All
    Say i have a web page with two frames. In one i define some
    variables, for example x=3, y=2 and z=0.
    In the other frame i have a button, which when pressed runs a
    javaScript function which adds x and y and stores the answer in z
    then outputs z in an alert box.
    I've tried sticking window. and document. in front of x, y
    and z, this didn't work.
    javaScript in Frame1:
    <script type="text/javascript"><!--
    x=3; y=2; z=0;
    // --></script>
    javaScript in Frame 2:
    <script type="text/javascript"><!--
    function add() {
    z=x+y;
    alert("The answer is " + z)
    // --></script>
    What word followed by a fullstops do i need to put in front
    of the variables to make them accessible to frame 2?
    Thanks
    Chopo

    Robert E Boughner wrote:
    > Chopo^2 wrote:
    >
    >> Hey All
    >>
    >> Say i have a web page with two frames. In one i
    define some
    >> variables, for example x=3, y=2 and z=0.
    >> In the other frame i have a button, which when
    pressed runs a
    >> javaScript function which adds x and y and stores
    the answer in z then
    >> outputs z in an alert box.
    >> I've tried sticking window. and document. in front
    of x, y and z,
    >> this didn't work.
    >>
    >> javaScript in Frame1:
    >> <script type="text/javascript"><!--
    >> x=3; y=2; z=0;
    >> // --></script>
    >>
    >> javaScript in Frame 2:
    >>
    >> <script type="text/javascript"><!--
    >> function add() {
    >> z=x+y;
    >> alert("The answer is " + z)
    >> }
    >> // --></script>
    >>
    >> What word followed by a fullstops do i need to put
    in front of the
    >> variables to make them accessible to frame 2?
    >>
    >> Thanks
    >>
    >> Chopo
    >>
    >
    > Assuming they are both in the same frame set, you can
    use something like
    > this:
    >
    > function add() {
    > top.frames[0].z=top.frames[0].x+top.frames[0].y;
    > alert("The answer is " + top.frames[0].z)
    > }
    function add() {
    top.frames[0].z= +top.frames[0].x+ +top.frames[0].y;
    alert("The answer is " + top.frames[0].z)
    } or
    function add() {
    with(top.frames[0]){
    alert("The answer is " + +x + +y)
    Mick
    >
    > Your second frame would be referenced as top.frames[1].

  • About XML/XSL and Javascript : Plz Help Urgent

    Hai , I am developing one module which invloves XML database ,XSL and Javascript.
    In this I want to transform XML data to XHTML form using XSLT .,
    I have done this ,(using xsl templates ,In my form two radio buttons one dropdown box and two text boxes are there .).
    All the information which ever is displayed coming from XML .,
    But I want to validate this elements (which are in xslt ,ie checking text box is empty or not ..)
    Where I have to add script in XSL .,
    Plz give simple example on this ,
    I am sending this code ,plz have a look at this ,,
    XML -----+ ---XSLT---------------> XHTML(HTML) (where validation is required)*
    Hotels.xml
    ==============>
    <Services>
         <Service>
              <Hotels type="radio" title="Hotel" groupname="service" default="true"/>
              <HotelsFlights type="radio" title="Flight+Hotel" groupname="service"/>
         </Service>
         <Hotels>
              <Destination title_d="Destination :">          
                   <DestinationPlace type="OPTION" id="" title_d="Select Destination" value_d="Select Destination" defalut="true"/>
                   <DestinationPlace type="OPTION" id="" title_d="Aruba" value_d="Aruba" />
              </Destination>
              <HotelChoice title_hc="Hotels :">
                   <choice type="OPTION" id=" " title_h="AmsterDam Manor Beach" value_h="AmsterDam Manor Beach"/>
                   <choice type="OPTION" id=" " title_h="Wyndham Aruba Beach" value_h="Wyndham Aruba Beach"/>
              </HotelChoice>
              <Dates>
                   <CheckIn type="INPUT" title_dt="Check In :" id="chkin" name="chkin" size_dt="10" maxlength="10">mm/dd/yyyy</CheckIn>
                   <CheckOut type="INPUT" title_dt="Check Out :" name="chkout" size_dt="10" maxlength="10">mm/dd/yyyy</CheckOut>
              </Dates>
              <RoomNos title="No.of Rooms :">
                   <room type="OPTION" id="" titl="1" valu="1"/>
                   <room type="OPTION" id="" titl="1" valu="2"/>
                   <room type="OPTION" id="" titl="1" valu="3"/>
              </RoomNos>
              <Submit tile="Search :" type="submit" id="search" value="Search"/>
         </Hotels>
    </Services>
    Hotels.xsl-
    ------------->
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <xsl:template match="/">
         <html>
         <head>
         <script language="javascript">
         function RadioFunc()
              var result;
              alert(" Radio ");
              result +=document.write("<TABLE >");
              result +=document.write("<TR><TD>"+'Praveen'+"</TD></TR>");
              result +=document.write("</TABLE>");
              alert("Result "+result);
         function validateForm()
              alert("Before validating");
              var chkindate= document.getElementById(chkin).value;
              alert(chkindate);
         </script>
         </head>
         </html>
         <xsl:apply-templates/>
    <xsl:if test="@value_d='Select Destination'">
                        alert("Please Enter Destination");
              </xsl:if>
    </xsl:template>
    <xsl:template match="Services" >
         <form name="myform" action="two.jsp" method="get" >
              <table bgcolor="lightgreen" width="350" height="200" border="1" >
              <tr><td><xsl:apply-templates/></td></tr>
              </table>
         </form>
    </xsl:template>
    <xsl:template match="Service">
         <table border="0" align="center" valign="top"><tr>
         <xsl:for-each select="*">
              <td align="left"><xsl:value-of select="@title"/></td>
              <td align="center">
              <input type="{@type}" onClick="RadioFunc()">
                   <xsl:attribute name="Name">
                        <xsl:value-of select="@groupname"/>
                   </xsl:attribute>
                   <xsl:attribute name="value">
                        <xsl:value-of select="@value"/>
                   </xsl:attribute>
                   <xsl:if test="@default='true'">
                        <xsl:attribute name="checked"/>
                   </xsl:if>
              </input>
              </td>
         </xsl:for-each>
         </tr></table>
    </xsl:template>
    <xsl:template match="Hotels/Destination">
    <xsl:value-of select="@title_d"/>
         <SELECT id="dest" name="dest">
         <xsl:for-each select="*">
              <xsl:element name="{@type}">
                   <xsl:value-of select="@value_d"/>
              </xsl:element>
         </xsl:for-each>     
         </SELECT>
    </xsl:template>
    <xsl:template match="Hotels/HotelChoice">
    <xsl:value-of select="@title_hc"/>
    <SELECT id="hcid" name="hcid">
         <xsl:for-each select="*">
              <xsl:element name="{@type}">
                   <xsl:value-of select="@value_h"/>
              </xsl:element>
         </xsl:for-each>
    </SELECT>
    </xsl:template>
    <xsl:template match="Hotels/Dates">
    <table><tr>
    <xsl:for-each select="*">
              <td>
                   <xsl:value-of select="@title_dt"/>
              </td>
              <td>
              <xsl:element name="{@type}" >
                   <xsl:attribute name="size">
                        <xsl:value-of select="@size_dt"/>
                   </xsl:attribute>
                   <xsl:attribute name="maxlength">
                        <xsl:value-of select="@maxlength"/>
                   </xsl:attribute>
                   <xsl:attribute name="value">
                        <xsl:value-of select="text()"/>
                   </xsl:attribute>
              </xsl:element>
              </td>
    </xsl:for-each>
    </tr></table>
    </xsl:template>
    <xsl:template match="Hotels/RoomNos">
    <table align="center"><th>Travellers</th>
    <tr><td><xsl:value-of select="@title"/></td>
    <td><SELECT id="rooms" name="rooms">
              <xsl:for-each select="*">
                   <xsl:element name="{@type}">
                        <xsl:value-of select="@valu"/>
                   </xsl:element>
              </xsl:for-each>     
    </SELECT>
    </td></tr>
         </table>
    </xsl:template>
    <xsl:template match="Hotels/Submit">
         <table align="center" border="0" >
         <tr>
         <td align="center">
              <input type="{@type}" onclick="validateForm();">
                   <xsl:attribute name="value">
                        <xsl:value-of select="@value"/>
                   </xsl:attribute>
              </input>
         </td>
         </tr>
         </table>
    </xsl:template>
    </xsl:stylesheet>
    ======================================================

    Hi
    This is not the forum for this type of question ...sorry. Try the XMLDB forum, XML DB
    Tim

  • What is the diffrence between a javabean and  EJB

    hi!
    what is the diffrence between a javabean and entreprise jvaabeans! i mean which are the uitilization featires of eaxh one !

    i am seeking for a solution for my problem , in fact i ma trying to implement and develop an application with java that allows a certain range of IP adresses to be connected to a database server in order to extract the suitable data from the server .
    let me explain mor ethe suitation , in fact what i am loking for is to use javabeans to grant my application much more consistence and pertinence : si i am asking if it could be possible to use javabeans in my case especially if i am not trying to developp a web application but a cleint /server one allowing some services.
    The application is in fact dealing with a stock exchange market and what i am trying to do is to grant particilar registrated customers to have the informations that they need ( portofolio, currency's status, market indicators, .) also drawing some charts decribing rates, variations, and others specefic financial caracterestics .So , if we consider that this application is not a web application ( no HTTP request and no servers like apache or others ) how it is possible to use javabeans and not EJB to build the application? i mean what could be suitable and preferable to rely on and dvelop to ensure a good java application !!
    if you need more details to help you find the answer for me don't hesitate to answer me back !!
    Someone here gave me that answer
    use RMI to code the services and (Updateable) Value Objects to pass the information between tiers.
    RMI is an all-java distributed component framework (ie. EJB, CORBA, DCE/RPC, DCOM, etc.), that is very suitable for developing non-containerized multi-tier applications. Refer to the RMI trail in the Java Tutorial as a starting point for coding RMI solutions (http://java.sun.com/docs/books/tutorial/index.html). Under this scenario you would code the database access service as an RMI service (server-side). Client/server communication should be facilitated through the use of JavaBeans/classes that wrap the information being passed (customer information, portfolio details, market information, etc.) - these are refered to as 'Updateable Value Objects' (a design pattern). Graphing and charting would be handled in your client from the information received from the (RMI) server. GUI JavaBeans can be used to provide this functionality as well as other client-side services. There are numerous "shrink-wrapped" components for GUIs available on the market just peruse any Java magazine to find them.
    but how comes? how can i do it !! and where can i find more information please about 'Updateable Value Object "
    thanks

  • Error using java and javascript

    I have a jsp page that links to a bean and is working fine (getting data from the database).
    On a html form I have a button with a picture that fires off javascript when clicked:
    <BUTTON TYPE=reset onclick=showinfo('<%=index%>')>
    <IMG SRC="http://localhost:8080/Portal/Images/q2.bmp" ALT="Info">
    </BUTTON>
    The javascript function just opens a new window and displays the text sent in:
    <Script Language=JavaScript>
    function showinfo(arrayindex)
    InfoWin=window.open("","InfoWin","width=345,height=220");
    InfoWin.document.write(arrayindex);
    return false;
    </Script>
    Well in the above example index is a number (pulled from the database using a java bean and javascript converts it into a string then the function displays it correctly. If I replace <%=index%> with regular text it works fine as well(because java isn't used to pull data)! The problem occurs when I retrieve text data from the database and send it to the function. The web page gives errors about a nonterminating string. But I can move the code to somewhere else on the form(as long as I don't send it to java script) and it will print the text to the screen. I can also view the source of the web page and the html shows the text from the data base as if I hard coded the text into the javascript!!!!!!!!!!!!!!!!!
    This must be a bug between java and javascript!
    -can pass numbers(from a database) between the two
    -can't pass text (from a database)between the two
    Any info would help!

    Found the problem myself!
    I am using an odbc connection to msaccess and the spaces in the text was messing things up!
    After taking out the spaces it worked again.

  • Text and/or repeating frames run off page ...

    Please help. It's very hard to believe that Oracle Reports 6i does not have a way of keeping text and/or frames from running off the physical page. My frames and text boxes have thier vertical size set to variable, and I have set page protect to yes, although this does not seems to help.
    Will setting the page length to the correct number of lines in between the margins help, there must be a way of keeping this from happening.....please help!

    hello,
    by setting the frame elasticity to variable, you allow the frames to shring and expand regardless of the page-size. to restrict it to a specific page size, the out-most frame must represent the boundries and must be set to fixed.
    regards,
    the oracle reports team

  • Use of HTML and Javascript within EP

    I have a newbie question:
    I have several HTMl documents with javascript embedded like e.g. various calculators we use on the current website.
    If I want to migrate these html sources to EP content, what can I best do than?
    I assume that all existing html and javascript renders as normal without too many development involved?
    Is there a good example how-To source which I can use to demonstrate this?
    many thanks for your help

    Hi,
    Well there are two options:
    <b>1) If you are interested to make the portal component and then use in Portal.
    2) If you want to use your earlier HTML document as it is inside the portal.</b>
    In case 1 you need to make the Portal objects and then make a portal project. You can use javascript in that as well.
    In case 2 you can directly make the URL iView of the HTML document and then view it from the portal. Well this is not a good way of using your javascript. Personally I suggest you to go for Portal Project.
    I hope this help you!!
    Regards
    Pravesh
    PS: Please consider reewarding points.

  • Link in new tab opens blank and "javascript:subValue(1)" is seen in the address bar.

    On a specific website, when I left click a link it opens but when trying to open the link in a new tab, the new tab opens blank and "javascript:subValue(1)" is seen in the address bar. This website hosts many, many images which I hope to download using a bulk image save addon but those images must first be in separate tabs. Opening these links in new tabs is vital to the process.

    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!

  • How to view the first and the last frame of a clip or a selected range in the time line?

    How to view the first and the last frame of a clip directly or in a selected range in the time line ? Up arrow and down arrow keys changes only between the first frame of the consecutive clips. Even ; and ' does the same. I mean what is the shortcut keys for first to last and last to first frame of a clip? Help please.

    SELECT PurOrderNum,
    OrderDate
    FROM
    SELECT PurOrderNum,
    OrderDate,
    MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
    MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'
    )t
    WHERE OrderDate = MaxDate
    OR OrderDate = MinDate
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Filting html tags, css, and javascript with regex

    hi everyone,
    im writing a small application where a user types in a url, and the text of the webpage is displayed in a text area.
    ive got it to work, however it takes some time, and also alot of content i dont want is displayed - tags, scripts and sometimes css.
    initally i filtered out the html tags with a regular expression, but i still get alot of unwanted content.
    im not a confident java programmer, and the idea of parsing html, css and javascript is the scariest idea ever to me, so my next idea is to keep only everything between the <body> tags - everything above and below it is deleted - hopefully that should leave me only with the visible content on the site.
    ive messed around with regular expressions but i cant get it to work, can anyone help out?
    thanks alot,
    Torre

    Darryl.Burke wrote:
    I tried out the regexes I posted on the source of a forum page, which is not valid html (contains two each opening and closing body tags). With a bit of trial and error I was able to remove everything upto the first, and not the second, opening tag by using a reluctant qualifier, ^.*?, but couldn't for the life of me achieve removal of only the last closing tag, leaving the other, invalid one intact. How would you do that?Regexes always try to match the first occurrence of whatever they're looking for (the sentinel), and there's no way to change that behavior (but it would be handy if you could). What you have to do instead is make sure the rest of the regex can't match the sentinel. For that you need lookahead, and the simplest way to use it is to scan the rest of the text looking for the sentinel and, if it doesn't find one, go ahead and gobble up the remaining text: "(?is)</body>(?!.*</body).*$" However, if there are many occurrences of the sentinel, you could take a serious performance hit. Here's a much more efficient way: "(?is)</body>(?:[^<]++|<(?!/body>))*+$" After matching the sentinel, this regex gobbles up anything that's not the first character of the sentinel, or the first character as long as it isn't followed by the remaining characters of the sentinel. The advantages of this regex are that it never has to backtrack, and the lookahead is only applied when it's necessary, where the first regex applies it every time.

Maybe you are looking for