Define a context parameter not using web.xml

Dears,
With a web.xml file, it is possible to define a context parameter available in the web app via de ServetContext.getInitParameters method.
Is it possible to define a context parameter not using the web.xml file ? Can I, in a java Class, init a custom context parameter ? (for exampel, init as a context param a key/value pair read from a property file).
PS: the need is that the value (hmac key) currently define in the web.xml needs to be updated monthly. Apparently, under WebSphere (the app server we are using) changing the web.xml of the deployed app it not enought for it to be taken into account.
Sincerely,
Beno�t Bertrand

Is it possible to define a context parameter not
using the web.xml file ? Can I, in a java Class, init
a custom context parameter ? (for exampel, init as a
context param a key/value pair read from a property
file).Does it necessarily have to be a value retrieved through the context param ? AFAIK, there's no way you could programatically 'set' an init param, which going by the name, 'init param' is quite understandable.
You could define this value in a property file and read it in, in the init method. You should provide a mechanism to reload the new value after 'x' days. One approach is a Timer that does the job, do have a look at SteveJLuke's recommendations on the same in this thread
http://forum.java.sun.com/thread.jspa?threadID=637355&tstart=0cheers,
ram.

Similar Messages

  • How can I get the context-parm from a web.xml file using struts?

    Hello:
    I need get the context-param from the web.xml file of my web project using struts. I want configurate the jdbc datasource connection pooling here. For example:
    <context-param>
    <param-name>datasource</param-name>
    <param-value>jdbc/formacion</param-value>
    <description>Jdbc datasource</description>
    </context-param>
    and then from any Action class get this parameter.
    Similar using a simple server can be:
    /** Initiates new XServlet */
    public void init(ServletConfig config) throws ServletException {
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();) {
                   System.out.println(e.nextElement());
              super.init(config);
              String str = config.getInitParameter("datasource");
              System.out.println(str);
         public void doPost(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              // res.setContentType( );
              System.out.println("Got post request in XServlet");
              PrintWriter out = res.getWriter();
              out.println("nada");
              out.flush();
              out.close();
    but only this works for init-params, if I use
    <servlet>
         <servlet-name>MyServlet</servlet-name>
         <display-name>MyServlet</display-name>
         <servlet-class>myExamples.servlet.MyServlet</servlet-class>
         <init-param>
         <param-name>datasource</param-name>
         <param-value>jdbc/formacion</param-value>
    </init-param>
    </servlet>
    inside my web.xml. I need something similar, but using struts inside the action class for that I can get the context-params and call my database.
    Thank you

    To get context parameters from your web.xml file you can simply get the ActionServlet object from an implementing action object class. In the perform (or execute) method make the following call.
    ServletContext context = getServlet().getServletContext();
    String tempContextVar =
    context.getInitParameter("<your context param >");

  • How to run java servlet without using Web.xml?

    How to run servlet without using Web.xml? From a book, I know that web.xml descriptor is optional, but the book doesn't tell us how to run java servelet without web.xm descriptor. So how to do that? Thanks a lot.

    How to run servlet without using Web.xml?But Tomcat now uses a web.xml for its global server-wide configuration.
    If you'd like to invoke a servlet with:
    http://host/servlet/ServletName
    you have to enable the invoker servlet.
    [from an HTML]
      <FORM METHOD="POST" ACTION="/servlet/HGrepSearchSJ">
    [from resin.conf of Resin Web Server 2.1.12]
      <!--
         - The "invoker" servlet invokes servlet classes from the URL.
         - /examples/basic/servlet/HelloServlet will start the HelloServlet
         - class.  In general, the invoker should only be used
         - for development, not on a deployment server, because it might
         - leave open security holes.
        -->
      <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
    [from TOMCAT5.0.19/conf/web.xml, a global server-wide web.xml file]
      <!-- The "invoker" servlet, which executes anonymous servlet classes      -->
      <!-- that have not been defined in a web.xml file.  Traditionally, this   -->
      <!-- servlet is mapped to URL pattern "/servlet/*", but you can map it    -->
      <!-- to other patterns as well.  The extra path info portion of such a    -->
      <!-- request must be the fully qualified class name of a Java class that  -->
      <!-- implements Servlet (or extends HttpServlet), or the servlet name     -->
      <!-- of an existing servlet definition.     This servlet supports the     -->
      <!-- following initialization parameters (default values are in square    -->
      <!-- brackets):                                                           -->
      <!--                                                                      -->
      <!--   debug               Debugging detail level for messages logged     -->
      <!--                       by this servlet.  [0]                          -->
        <servlet>
            <servlet-name>invoker</servlet-name>
            <servlet-class>
              org.apache.catalina.servlets.InvokerServlet
            </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>0</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    ---comment out below----------------------------------------------------------
        <!-- The mapping for the invoker servlet -->
    <!--
        <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>
    -->

  • Email Alert Template Issue - List Alerts (Alert Me) emails not using customized XML alert template

    We have recently customized the XML alerts template (AlertTemplates.xml) for our site collection in SharePoint 2010 to exclude specific fields in the email when users who have subscribed using the "Alert Me" feature. We have renamed the
    custom alerts XML file and loaded the custom template in the following directory (%ProgramFiles%\Common Files\Microsoft Shared\Web server extensions\14\TEMPLATE\XML) and restarted IIS.  Once users subscribe to the alerts using the list "alert me"
    function they received the customized email as intended.
    We needed to auto-subscribe users to the email alerts so what we did was use a powershell script to add users to the alert subscriptions using the script shown below:
    Import-Csv D:\Temp\filename.csv | ForEach-Object{
    $webUrl=$_.WebUrl
    $listTitle=$_.List
    $alertTitle=$_.AlertTitle
    $subscribedUser=$_.SubscribedUser
    $alertType=$_.AlertType
    $deliveryChannel=$_.DeliveryChannel
    $eventType=$_.EventType
    $frequency=$_.Frequency
    $oldAlertID=$_.ID
    $web=Get-SPWeb $webUrl
    $testAlert = $web.Alerts | WHERE { $_.ID -eq $oldAlertID }
    IF ($testAlert) {
    $web.Alerts.Delete([GUID]$oldAlertID)
    Write-Host Old alert $oldAlertID deleted. -Foregroundcolor Cyan
    $list=$web.Lists.TryGetList($listTitle)
    $user = $web.EnsureUser($subscribedUser)
    $newAlert = $user.Alerts.Add()
    $newAlert.Title = $alertTitle
    $newAlert.AlertType=[Microsoft.SharePoint.SPAlertType]::$alertType
    $newAlert.List = $list
    $newAlert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::$deliveryChannel
    $newAlert.EventType = [Microsoft.SharePoint.SPEventType]::$eventType
    $newAlert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::$frequency
    if($frequency -ne "Immediate"){
    $AlertTime=$_.AlertTime
    $newAlert.AlertTime=$AlertTime
    $newAlert.Update()
    Write-Host Created $newAlert.Title for $subscribedUser . -Foregroundcolor Cyan
    } ELSE {
    Write-Host Alert $alertTitle for $subscribedUser already done. Moving on. -Foregroundcolor Magenta
    When we ran the script and added the users and restarted the service, all users who were auto-subscribed via this method get the email without the customizations that were done in teh custom alert template.  All users who manually subscribed on their
    own to the list using the "Alert Me" function would get the customized email.
    Does anyone know why users who manually subscribe to the alerts get the customized email, and users who were auto-subscribed using the powershell script do not get the customized email and get the standard generic email template?

    Hi  ,
    According to your code, it create a new alert using SPUser.Alerts.Add() method. For this method, it will create a new alert based on the predefined alert template by default.
    If you only assigned the custom alert template to the list, users who manually subscribe to the alerts get the customized email, but users who were auto-subscribed using the PowerShell script get the standard
    generic email template.
    For your issue, you can set the new alert ‘s alert template:
    http://social.technet.microsoft.com/Forums/en-US/1b19c12f-fc37-48cf-8b59-6c09f095dc23/custom-alert-email-templates-issue-list-alerts-emails-not-using-customized-xml-alert-template?forum=sharepointgeneralprevious
    Here is a good blog you can have a look:
    http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2007/12/07/customizing-alert-notifications-and-alert-templates-in-windows-sharepoint-services-3-0.aspx
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Eric Tao
    TechNet Community Support

  • What is the best way to find a file on the servers disk without using web.xml?

              What is the best way to find a file on the servers disk without using web.xml?
              I want to find a configuration file not contained within the war file I have
              created. Is there a way to pass information into the ServletContext with out
              rebuilding the ear or war files? Tomcat 4.0 can do this in its server configuration
              files. Does BEA have the equivalent?
              Regards,
              Eric
              

    You can specify the path to the file as a system property
              eg
              java -Dconfig.file.location=./mydirecotry/myfile.txt com.test.MyApp
              "Eric White" <[email protected]> wrote in message
              news:[email protected]..
              >
              > What is the best way to find a file on the servers disk without using
              web.xml?
              > I want to find a configuration file not contained within the war file I
              have
              > created. Is there a way to pass information into the ServletContext with
              out
              > rebuilding the ear or war files? Tomcat 4.0 can do this in its server
              configuration
              > files. Does BEA have the equivalent?
              >
              > Regards,
              > Eric
              

  • How to set up context parameter of a web application

    Hi,
    I am tring to deploy a ear file to J2EE Engine 7.1
    with the help of import feature of NWDS.
    Is there any option to set the value of the context parameters defined in web.xml inside the ear.
    Regards,
    Chitra

    Thanks for your response.
    Th e version no. of IE Tab is 4.0.20130422 and it is from https://addons.mozilla.org/en-US/firefox/addon/ie-tab/
    Look forward your reply.Thank you in advance.

  • Query on virtual column that is defined in XMLIndex does not use the index

    Hello,
    I am facing an issue in executing queries on a virtual column that is defined in an XMLIndex: it appears as if the index is not used.
    Database details:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    For this use case the XML documents adhere to the following XSD and are stored in an XMLType column in a table:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns="http://a_name_space/v1"
        targetNamespace="http://a_name_space/v1"
        elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
        <xsd:element name="fields">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="field" maxOccurs="unbounded">
                        <xsd:complexType>
                            <xsd:choice>
                                <xsd:element name="value" minOccurs="1" maxOccurs="1">
                                    <xsd:complexType>
                                        <xsd:simpleContent>
                                            <xsd:extension base="notEmptyString4000Type"/>
                                        </xsd:simpleContent>
                                    </xsd:complexType>
                                </xsd:element>
                                <xsd:element name="values" minOccurs="1" maxOccurs="1">
                                    <xsd:complexType>
                                        <xsd:sequence>
                                            <xsd:element name="value" minOccurs="1" maxOccurs="1">
                                                <xsd:complexType>
                                                    <xsd:simpleContent>
                                                        <xsd:extension base="notEmptyString4000Type">
                                                            <xsd:attribute name="startDate" type="xsd:date" use="required"/>
                                                            <xsd:attribute name="endDate" type="xsd:date" />
                                                        </xsd:extension>
                                                    </xsd:simpleContent>
                                                </xsd:complexType>
                                            </xsd:element>
                                        </xsd:sequence>
                                    </xsd:complexType>
                                </xsd:element>
                            </xsd:choice>
                            <xsd:attribute name="name" type="string30Type" use="required"/>
                            <xsd:attribute name="type" type="dataType" use="required"/>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:simpleType name="dataType">
            <xsd:annotation>
                <xsd:documentation>Char, Date, Number</xsd:documentation>
            </xsd:annotation>
            <xsd:restriction base="xsd:string">
                <xsd:enumeration value="C"/>
                <xsd:enumeration value="D"/>
                <xsd:enumeration value="N"/>
            </xsd:restriction>
        </xsd:simpleType>
        <xsd:simpleType name="string30Type">
            <xsd:restriction base="xsd:string">
                <xsd:maxLength value="30"/>
            </xsd:restriction>
        </xsd:simpleType>
        <xsd:simpleType name="notEmptyString4000Type">
            <xsd:restriction base="xsd:string">
                <xsd:maxLength value="4000"/>
                <xsd:pattern value=".+"/>
            </xsd:restriction>
        </xsd:simpleType>
    </xsd:schema>A field can have a single value as well as multiple values.
    The XMLIndex is defined as follows:
    CREATE INDEX test_xmltype_idx ON test_xmltype (additional_fields) INDEXTYPE IS XDB.XMLIndex
    PARAMETERS
    XMLTable dt_fld_tab (TABLESPACE "TAB_SPACE" COMPRESS FOR OLTP) ''fields/field''
    COLUMNS
    name varchar2(30 char) PATH ''@name''
    ,dataType varchar2(1 char) PATH ''@type''
    ,val varchar2(4000 char) PATH ''value/text()''
    ,vals XMLType PATH ''values/value'' VIRTUAL
    XMLTable dt_fld_multi_value_tab (TABLESPACE "TAB_SPACE" COMPRESS FOR OLTP) ''value'' passing vals
    COLUMNS
    val varchar2(4000) PATH ''text()''
    ,startDate varchar2(30 char) PATH ''@startDate''
    ,endDate varchar2(30 char) PATH ''@endDate''
    ');The following b-tree indexes are defined:
    create index dt_field_name_idx on dt_fld_tab (name);
    create index dt_field_value_idx on dt_fld_tab (val);
    create index dt_field_values_idx on dt_fld_multi_value_tab (val);And stats are properly computed before the queries are executed:
    call dbms_stats.gather_table_stats(user, 'test_xmltype', estimate_percent => null);Queries for single values are cost efficient and fast. With 600K rows in the table these return with 0.002 seconds.
    Queries for multi-valued fields / elements are not though, these result in a full table scan.
    Sample XML snippet:
    <fields>
      <field name="multiVal" type="C">
        <values>
          <value startDate="2013-01-01" endDate="2013-01-01">100</value>
          <value startDate="2014-01-01">120</value>
        </values>
      </field>
    </fields>Examples of costly and slow queries:
    select id from test_xmltype
    where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
    and xmlexists('/fields/field/values/value[@startDate="2013-01-01"]' passing additional_fields)
    and xmlexists('/fields/field/values/value[text()="100"]' passing additional_fields)
    select id from test_xmltype
    where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
    and xmlexists('/fields/field/values/value[@startDate="2013-01-01" and .="100"]' passing additional_fields);Whereas the following query on the multi valued field is fast:
    select id from test_xmltype
    where xmlexists('/fields/field/@name="multiVal"' passing additional_fields)
    and xmlexists('/fields/field/values/value[@startDate="2013-01-01"]' passing additional_fields);For the XPath /fields/field/values/value[@startDate="2013-01-01"] the index is used.
    Suspected cause: XPath issue for the value of a multi valued field, e.g. /fields/field/values/value[text()="aValue"].
    Any hints are appreciated: what am I overlooking here?
    Thanks in advance,
    -Sjoerd
    Edited by: user615230 on May 27, 2013 7:46 AM

    Hello,
    This is using binary XML. The table creation script is:
    create table test_xmltype
    (id number(14,0) not null primary key
    ,member_code varchar2(30 char) not null
    ,period_code varchar2(30 char) not null
    ,amount number(12,2) not null
    ,additional_fields xmltype
    );The schema is not registered in the database. Is that required? It is primarily used to generate Java classes that will be used in order to construct the XML documents.
    And you are right: for our initial investigation the sample XML documents are generated with a PLSQL routine and do not contain namespaces. But for the single valued fields there are also no namespaces and the queries on these are executed with very satisfactory plans.
    Thanks for the swift reply.
    -Sjoerd

  • Define global error page on global-web.xml

    Dear fellows:
    We want to create a common 404 web error page for all our J2EE applications. We have added these error pages to the global-web.xml through the Visual Administrator:
      on several  system local folders such as:
    usrsap<SID><j2ee-instance>j2eecluster
    usrsap<SID><j2ee-instance>j2eecluster<server-inst>
    usrsap<SID><j2ee-instance>j2eecluster<server-inst>apps
    usrsap<SID><j2ee-instance>j2eecluster<server-inst>sap.com
    However, everytime we provoke the server error in order to retreive this Global Error Web Page, the system does not seem to find our custom error page, giving the following message:
    The request can’t be processed.
    Details: Requested resource ( /testerrorpage.html ) not found.
    We have discovered that the application was not trying to look up for our web Error page, but for another one located inside the application. However, we don't want to add a specific application web page but a global one common for all of them.
    Since there is not any common folder, such as global/root folder, we don’t know where the custom error page should be placed. Do we need to do something else?
    We are currently using WAS: 6.40 SP 11 PatchLevel 89291.313.
    Does anyone know how to configure this global error page? It is possible to do it?
    Thank you
    Gonzalo
    Message was edited by: Gonzalo Pérez-Prim

    Hello,
    Yes, Uvaylo is right, the only way to edit the content of the global-web.xml is through the visual administrator --> Configuration Adapter.
    I have the same problem as Gonzalo, I have modified the global-web.xml and added custom errors pages for each HTTP error and exceptions. The big deal is when I try to specify in the <b>location</b> field of <b>error-page</b> item: I dont know where I should place my custom error page. I have tried the same paths as Gonzalo did with the same result, when the error event is raised the error page is not found. In the log appears the following entry:
    Processing an http request by the error page [/testerrorpage.html] finished with errors.
    Probably the exception [com.sap.engine.services.servlets_jsp.server.exceptions.ServletNotFoundException:
    Requested resource ( /custom_error.html ) not found.]
    thrown by the requested servlet [/testerrorpage.html] cannot be processed.
    The error is: com.sap.engine.services.servlets_jsp.server.exc
    Please help! Where can I place my custom error pages, to make them available for all the applications of the server?
    Thanks in advance for your help!

  • Problem if i use web.xml

    hi,
    i am developing a project using servlets and jsp's, i am using JSTL for the jsp pages (c.tld) but it is not working if there is web.xml file with out this it is working fine
    i dont know what exacltly the problem plzz xove this problem
    cheers,
    Aleem Basha,

    What error message are you getting?
    What Server are you using? Version?
    What version of JSP are you using? 1.2 or 2.0?
    What version of JSTL are you using? 1.0 or 1.1?
    See [url http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0]this thread (reply #6)  for version issues using JSTL in various servers.

  • Display error page using web.xml error-page

    I need to dispaly error page when IOException in thrown. How to do that with web.xml error-page tag?
    start.jsf
    public String doButton1Action() throws IOException{
              String value = getText1().getValue().toString();
              try {
                   File f = new File(value);          
                   InputStream in = new FileInputStream(f);
              } catch (IOException e) {
                   throw new IOException();
              return "success";
         }I have this in web.xml:
         <error-page>
              <exception-type>java.io.IOException</exception-type>
              <location>/ioerror.jsp</location>
         </error-page>

    I tried that earlier but then I get error just printed to console and HTTP 500 - Internal server error -page, bubt not my errorPage.
    [26.1.2007 21:19:16:543 EET] 00000038 jsf           E com.sun.faces.lifecycle.InvokeApplicationPhase execute #{pc_Start.doButton1Action}: javax.faces.el.EvaluationException: java.io.FileNotFoundException: c:\temp\ghostfile.jpg
                                     javax.faces.FacesException: #{pc_Start.doButton1Action}: javax.faces.el.EvaluationException: java.io.FileNotFoundException: c:\temp\ghostfile.jpg
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:79)
         at javax.faces.component.UICommand.broadcast(UICommand.java:312)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:298)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:412)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:220)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
         at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
         at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
         at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
         at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
         at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
         at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
         at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
         at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
         at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
         at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
         at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
    Caused by: javax.faces.el.EvaluationException: java.io.FileNotFoundException: c:\temp\ghostfile.jpg
         at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:131)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:73)
         ... 25 more

  • Custom Alert Email Templates Issue - List Alerts emails not using customized XML alert template

    I have recently customized the XML alerts template (AlertTemplates.xml) for our site collection in SharePoint 2010 to exclude specific fields in the email when users who have subscribed to a list using the "Alert Me" feature.  I
    have renamed the custom alerts XML file and loaded the custom template in the following directory (%ProgramFiles%\Common Files\Microsoft Shared\Web server extensions\14\TEMPLATE\XML) and
    restarted IIS.  Once users subscribe to the alerts using the list using the "alert me" function they received the customized email as intended. 
    We needed to auto-subscribe users to the email alerts so what I did was used a powershell script to add users to the alert subscriptions using the script shown in below:
    Import-Csv D:\Temp\filename.csv | ForEach-Object{
    $webUrl=$_.WebUrl
    $listTitle=$_.List
    $alertTitle=$_.AlertTitle
    $subscribedUser=$_.SubscribedUser
    $alertType=$_.AlertType
    $deliveryChannel=$_.DeliveryChannel
    $eventType=$_.EventType
    $frequency=$_.Frequency
    $oldAlertID=$_.ID
    $web=Get-SPWeb $webUrl
    $testAlert = $web.Alerts | WHERE { $_.ID -eq $oldAlertID }
    IF ($testAlert) {
    $web.Alerts.Delete([GUID]$oldAlertID)
    Write-Host Old alert $oldAlertID deleted. -Foregroundcolor Cyan
    $list=$web.Lists.TryGetList($listTitle)
    $user = $web.EnsureUser($subscribedUser)
    $newAlert = $user.Alerts.Add()
    $newAlert.Title = $alertTitle
    $newAlert.AlertType=[Microsoft.SharePoint.SPAlertType]::$alertType
    $newAlert.List = $list
    $newAlert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::$deliveryChannel
    $newAlert.EventType = [Microsoft.SharePoint.SPEventType]::$eventType
    $newAlert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::$frequency
    if($frequency -ne "Immediate"){
    $AlertTime=$_.AlertTime
    $newAlert.AlertTime=$AlertTime
    $newAlert.Update()
    Write-Host Created $newAlert.Title for $subscribedUser . -Foregroundcolor Cyan
    } ELSE {
    Write-Host Alert $alertTitle for $subscribedUser already done. Moving on. -Foregroundcolor Magenta
    When I ran the script and added the users and restarted the service, all users who were auto-subscribed via this method would get the email without the customizations that were done in the custom template.  All users who manually subscribed to the list
    using the "Alert Me" function would get the customized email. 
    Does anyone know why users who manually subscribe would get the custom email alert and why users who were auto-subscribed using the powershell script do not get the custom email alert?

    Hi  ,
    According to your description, my understanding is that users who were auto-subscribed using the PowerShell script do not get the custom email alert.
    For your issue, it can be caused by the auto-subscribed alert email which is generated by PowerShell script is  using OOTB alert template. You can add the following script into your script for setting
    the alerts’ alert email template:
    $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
    $AlertsTemplateCollection =new-object Microsoft.SharePoint.SPAlertTemplateCollection($contentService)
    $newAlert.AlertTemplate = $AlertsTemplateCollection["YOUR_UNIQUE_TEMPLATE_NAME_VALUE"]
    Reference:
    http://sadomovalex.blogspot.com/2012/03/one-problem-with-updating-alert.html
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Eric Tao
    TechNet Community Support

  • How to read Standard JSR Portlet Web.xml's context-param

    Hi
    I am completely new to Java.
    I want to keep some configuration in Web.xml in Context param. My Web.xml looks like
    <context-param>
    <param-name>ConfigUrl</param-name>
    <param-value>http://localhost:8083/</param-value>
    </context-param>
    How can I read these values? Can I read these values directly in my JSP file or will I have to read it in my Portlet Class in some function.
    Thanks

    As soon as I use portletConfig, it gives me NullPointerException. I am definitely using <portlet:defineObjects/>
    My Jsp looks as :
    <%@ page contentType = "text/html; charset=windows-1252"
    pageEncoding = "windows-1252"
    import = "javax.portlet.*, java.util.*, port.Port, port.resource.PortBundle,javax.portlet.PortletContext"%>
    <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
    <portlet:defineObjects/>
    <%
    PortletContext ctx = portletConfig.getPortletContext();
    String configpath = "Hello";
    %>
    <label>Welcome</label>
    <label><%=configpath%></label>

  • What is web.xml and why it is used?

    hi,
    am new to servlet technology, i tried to find a topic like this in this fourm also in google but didn't get a exact one. can anybody explain me or suggest me some resource about this.
    thanx in advance.
    Max

    hi stevejluke,
    thanx for the correct link.
    nx for the correct link. but what i in doubt with is
    why we should use web.xml? may be my question is very
    silly, may be too basic, forgive me for that...
    Thanx & Regards,
    SaikatAt the most basic level:
    There are several versions of the Servlet specification, You need the web.xml to tell the server which version of the spec your application conforms to so the server knows how to deal with different things.
    If you have a servlet, you also need the web.xml to define what URL signals a request that should be handled by your servlet.
    At this point, you need to sit down and read a book. Do what it says, blindly at first. Just do what it says (but do try to understand the 'what' of it, just don't question the 'why'). After you have a few applications running, go back and ask yourself this question again and try to see what you are using the web.xml for in those applications you have.

  • Bug in lookup of web.xml env-entry in WL 7.0?

    If I create an "env-entry" block for a name (e.g. "MySchemaName") in my web.xml
    file and deploy the web app, I should be able to look up the name from my webapp
    with the line:
    <br>
    myInitialContext.lookup("java:comp/env/MySchemaName");
    <br>
    However when I do that I get the error message:
    <br>
    javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/MySchemaName'
    <br>
    Note that the "comp/env" prefix has been changed to "comp.env". This worked under
    WL 6.1. Is this a bug in WL 7's JNDI or a bug in the error message or both or
    something else altogether?
    The immediately previous line successfully performs an EJBHome lookup using the
    same Initial Context object. The main difference is that the EJBHome name is defined
    thru the EJB deployment descriptors, not the web.xml.
    Thanks,
    Steve

    Ah, I was trying to do a lookup from session bean for the env-entry defined in
    the web.xml. After reading the J2EE spec, I see this just won't work. env-entries
    are only accessible from within the component where they are defined.
    Still the error message with "comp.env" instead of the expected "comp/env" is
    a bit confusing.
    Not much traffic in this newsgroup, is there?
    Steve
    "Steve Ditlinger" <[email protected]> wrote:
    >
    >
    >
    If I create an "env-entry" block for a name (e.g. "MySchemaName") in
    my web.xml
    file and deploy the web app, I should be able to look up the name from
    my webapp
    with the line:
    <br>
    myInitialContext.lookup("java:comp/env/MySchemaName");
    <br>
    However when I do that I get the error message:
    <br>
    javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/MySchemaName'
    <br>
    Note that the "comp/env" prefix has been changed to "comp.env". This
    worked under
    WL 6.1. Is this a bug in WL 7's JNDI or a bug in the error message or
    both or
    something else altogether?
    The immediately previous line successfully performs an EJBHome lookup
    using the
    same Initial Context object. The main difference is that the EJBHome
    name is defined
    thru the EJB deployment descriptors, not the web.xml.
    Thanks,
    Steve

  • FORMAUTH Filter in orion-web.xml ignored

    I am trying to use a JAAS Custom Login Module with a customized logon.jsp (and Struts). So I defined a FORMAUTH Filter in orion-web.xml to intercept the logon.
    However, Oracle 10g 10.1.3.2 did not deploy it. Why? How can I fix this problem?
    ===========================================================
    Deployed Application:
    {ORACLE_10_1_3_2_HOME}\j2ee\home\application-deployments\{APPLICATION}\{APPLICATION_WAR}\orion-web.xml contained:
    <?xml version="1.0"?>
    <orion-web-app
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-web-10_0.xsd"
         deployment-version="10.1.3.1.0"
         deployment-time="1189531757046"
         development="true"
         jsp-cache-directory="./persistence"
         jsp-cache-tlds="standard"
         simple-jsp-mapping="false"
         temporary-directory="./temp"
         servlet-webdir="/servlet"
         context-root="visit"
    schema-major-version="10" schema-minor-version="0" >
         <web-app-class-loader search-local-classes-first="true" include-war-manifest-class-path="true" />
         <web-app>
         </web-app>
    </orion-web-app>
    ===========================================================
    BUT: APPLICATION.EAR structure:
    APPLICATION_WAR\WEB-INF\orion-web.xml contained:
    <?xml version="1.0"?>
    <!DOCTYPE orion-web-app PUBLIC "-//ORACLE//DTD OC4J Web Application 9.04//EN" "http://xmlns.oracle.com/ias/dtds/orion-web-9_04.dtd">
    <orion-web-app
         deployment-version="10.1.3.1.0"
         temporary-directory="./temp"
         internationalize-resources="false"
         default-mime-type="application/octet-stream"
         jsp-cache-directory="./persistence"
         servlet-webdir="/servlet"
         development="true">
              <web-app-class-loader search-local-classes-first="true" include-war-manifest-class-path="true" />
    <web-app>
    <filter>
    <filter-name>AuthenicationFilter</filter-name>
    <filter-class>gov.dhs.visit.filter.AuthenicationFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>AuthenicationFilter</filter-name>
    <dispatcher>FORMAUTH</dispatcher>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>
    </web-app>
    </orion-web-app>

    I've used this before, and it worked fine. The only difference I can see is that you have a url-pattern element in the filter-mapping config.
    In the short term, try removing that and see if it then works.
    -steve-

Maybe you are looking for