Applying Private & Protected methods inside JSP

I am trying to apply (or copy) codings from Servlet into JSP.
One of the issue that I encountered was bringing Private and Protected methods that were listed inside the Servlet class (this case: public abstract class CatalogPage).
If I only copy everything inside "Public void doGet", JSP would not work.
1) My question is, is it better approach to apply Private and Protected method beside wrapping around with ( <%! %> (with !)) (like below)?
I think I heard about using " ! " for private methods somewhere in the internet..
Here is what I have at JSP.
<%!
Private CatalogItem[] items;
Private String[] itemIDs;
private String title;
protected void setItems(String[] itemIDs) {
protected void setTitle(String title) {
%>
<%
if (items == null) {
response.sendError(response.SC_NOT_FOUND,
"Missing Items.");
return;
%>
2) Is there any other ways I could make the functionality of Private and Protected methods
work inside the JSP's <% %>?
Thank you.
Here is the original Servlet code.
public abstract class CatalogPage extends HttpServlet {
  private CatalogItem[] items;
  private String[] itemIDs;
  private String title;
  protected void setItems(String[] itemIDs) {
    this.itemIDs = itemIDs;
    items = new CatalogItem[itemIDs.length];
    for(int i=0; i<items.length; i++) {
      items[i] = Catalog.getItem(itemIDs);
protected void setTitle(String title) {
this.title = title;
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
if (items == null) {
response.sendError(response.SC_NOT_FOUND,
"Missing Items.");
return;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=\"CENTER\">" + title + "</H1>");
CatalogItem item;
for(int i=0; i<items.length; i++) {
out.println("<HR>");
item = items[i];
// Show error message if subclass lists item ID
// that's not in the catalog.
if (item == null) {
out.println("<FONT COLOR=\"RED\">" +
"Unknown item ID " + itemIDs[i] +
"</FONT>");
} else {
out.println();
String formURL =
"/servlet/coreservlets.OrderPage";
// Pass URLs that reference own site through encodeURL.
formURL = response.encodeURL(formURL);
out.println
("<FORM ACTION=\"" + formURL + "\">\n" +
"<INPUT TYPE=\"HIDDEN\" NAME=\"itemID\" " +
" VALUE=\"" + item.getItemID() + "\">\n" +
"<H2>" + item.getShortDescription() +
" ($" + item.getCost() + ")</H2>\n" +
item.getLongDescription() + "\n" +
"<P>\n<CENTER>\n" +
"<INPUT TYPE=\"SUBMIT\" " +
"VALUE=\"Add to Shopping Cart\">\n" +
"</CENTER>\n<P>\n</FORM>");
out.println("<HR>\n</BODY></HTML>");
null

I am trying to apply (or copy) codings from Servlet into JSP.What benefit is there to copying code from a servlet to a JSP? Is the servlet "working"?
One of the issue that I encountered was bringing
Private and Protected methods that were listed inside
the Servlet class.
If I just copy everything inside "Public void doGet",
JSP would not work.Sounds like you need a redesign.
1) My question is, is it better approach to apply
Private and Protected method beside wrapping around
with ( <%! %> (with !)) (like below)?
I think I heard about using " ! " for private
methods somewhere in the internet..Never heard of such a thing. Please cite the link if you have it.
Here is what I have at JSP.Please, I can't look. This is wrong on so many levels. You've got scriptlet code, CSS style stuff, embedded HTML in one unmaintainable mess.
Learn JSTL and CSS. Do not, under any circumstances, put scriptlet code in your JSP.
The right way is to use the JSP purely as display and keep those protected and private methods on the server side where they belong. Have the JSP make a request to another object to do some work, get the result, and displa it.
%

Similar Messages

  • How to use protected method in jsp code

    Could anyone tell me how to use protected method in jsp code ...
    I declare a Calendar class , and I want to use the isTimeSet method ,
    But if I write the code as follows ..
    ========================================================
    <%
    Calendar create_date = Calendar.getInstance();
    if (create_date.isTimeSet) System.out.println("true");
    %>
    ============================================================
    when I run this jsp , it appears the error wirtten "isTimeSet has protected access in java.util.Calendar"

    The only way to access a protected variable is to subclass.
    MyCalendar extends Calendar
    but I doubt you need to do this. If you only want to tell if a Calendar object has a time associated with it, try using
    cal.isSet( Calendar.HOUR );

  • Forcing invocation of private/protected methods

    Has anyone, any idea how can be forced the invocation of a private/protected method on a object. The client that invokes the method has a reference to the object and is declared in a different object than the targeted object.
    See code below:
    package src.client;
    import java.lang.reflect.Method;
    import src.provider.CPBook;
    public class Tester {
         public static void main(String [] args) {
              CPBook targetObj = new CPBook();
              Method [] mths = targetObj.getClass().getDeclaredMethods();
              Method targetMth = null;
              for (int i = 0; i < mths.length; i++) {               
                   if ("getMgr".equals(mths.getName())) {
                        targetMth = mths[i];
              if (targetMth != null) {
                   try {
                        Object [] obj = new Object[1];
                        obj[0] = new Boolean(true);
                        targetMth.invoke(b, obj);
                   } catch (Exception e) {                    
                        e.printStackTrace();
    package src.provider;
    public class CPBook {
         public void startDownload() {                    
         public void stopDownload() {     
         protected void getMgr(boolean bool) {
              System.out.println("------- OK ------- : " + bool);
    }Thank you.
    Best regards.

    The class java.lang.reflect.Method has a setAccessible(boolean) method on it. I think that's what you're asking for. Code that makes use of it might run into trouble if a security manager is involved, though. Generally, methods are private for a reason, too, so if your code depends on a private method, it's dependent on an implementation detail it probably shouldn't be concerned about, or even aware of

  • How to create a byte[] as parameter for a Method inside the Controller

    Hi Experts,
    I want to create a method getCachedWebResource inside the component controller which has a parameter file which is of type byte[].
    But in Netweaver Developer Studio I am not able to create this parameter with type byte[] .
    When I try creating a parameter of this type (byte[]) . I get only byte from drop down and  below Array type checkbox is disabled.
    Please help me in this regards.
    I am already highly obliged to his forum with lots of useful answers. Hoping the same this time too
    Best Regards,
    Roby..

    Robert-
    There are two ways of achieving this:
    1. Create a private getCachedWebResource() method inside your component controller's others section. i.e. do not create a method on the Methods tab, but instead code the method directly into the controller.
    2. Create a parameter of type java.lang.Byte[ ] instead of byte[ ]. This can be done by clicking on the Browse button next to the Type and then choosing the Java Native Type radio button. In the Java Native Type input field provide java.lang.Byte. Click on Ok and you should see the Array Type option getting enabled. Check it, and in the method you should convert from java.lang.Byte to byte.
    I would stick to option (1)
    Cheers-
    Atul

  • Private static MyInnerClass extends OtherClass + protected methods

    Hi!
    Consider this case:
    public class A {
    private static class A1 extends B {
    // this would resolve the error:
    //       protected static void b() { B.b(); }
    void a() { A1.b(); } // ERROR: B.b() is inaccessible
    public class B {
    protected static void b() {}
    }(Where A and B are in different packages.)
    Why is B.b() inaccessible here?
    A1 extends B, so it sees its protected methods.
    A is a nesting class of A1, so it sees the protected methods of A1.
    What am I missing here?
    Thank you!
    Agoston

    OK, my mistake, I missed the part about different
    packages.
    However the following further inner class of A
    compiles for me:
         private static class A2 extends A1
              A2()
                   b();
                   A1.b();
         }using the OP's original code without A1.b().That's what I was talking about: b() can be called from children, but not from the nesting class.
    >
    The statement quoted from the JCP exam is not
    correct. The inherited protected member is available
    to subclasses of A1, so the protected member
    b() doesn't 'become private' at all. It stays as is
    was, i.e. protected, i.e. accessible within the
    original package or to subclasses.If it stays protected, why can't the nesting class see it? (Once again, a protected method defined in A1 and not inherited from B is visible from A.)
    It seems as if the inherited protected method teleports into some mysterious realm of visibility levels between private and protected. (I.e. it's like protected, only from a nesting class it's seen as super-private - since the nesting class should even be able to see the private methods of its inner class, shouldn't it?)
    This whole inconsequent behavior on the part of the compiler feels like a huge bug to me.
    Nothing changes.Unfortunately. :)
    Agoston

  • Can i write Html code inside JSP method???

    hi i am newbie to jsp and servlets. i am working on a project where i have to use same html code for two conditions in jsp. my question is can i write that html code inside any method in jsp?? and then can i call that method within that if and else scope. can anyone help me with this??

    I don't think that does what you think it does.
    <%!
    void renderStateSelect(String default) { %>Creates a method with that signature and an open brace...
    <select name="state"> puts:
    out.println("<select name=\"state\">");
    into the _jspService method
    <%!
    // logic to loop thru states
    %>Puts the loop logic after the brace opening up the method renderStateSelect
    </select>puts
    out.println("</select>");
    in the _jspService method
    <%!
    %>Closes the renderStateSelect method.
    So if I do this:
    <html>
    <body>
    <%!
    void renderStateSelect(String def) { %>
    <select name="state">
    <%!
    // logic to loop thru states
    %>
    </select>
    <%!
    %>
    Hello<br/>
    <% renderStateSelect("none"); %>
    Everybody
    </body>
    </html>The html output is:
    <html>
    <body>
    <select name="state">
    </select>
    Hello<br/>
    Everybody
    </body>
    </html> The 'renderStateSelect method does not render the state select. The _jspService method does, in place where the HTML is written in the JSP file.  As another look, the translated servlet looks like this:
    package org.apache.jsp;
    public final class IsThisOk_jsp extends org.apache.jasper.runtime.HttpJspBase
        implements org.apache.jasper.runtime.JspSourceDependent {
    void renderStateSelect(String def) {
    // logic to loop thru states
      public void _jspService(HttpServletRequest request, HttpServletResponse response)
            throws java.io.IOException, ServletException {
        try {
          out.write("<html>\r\n<body>\r\n");
          out.write("<select name=\"state\">\r\n");
          out.write("</select>\r\n");
          out.write(" \r\nHello<br/>\r\n");
    renderStateSelect("none");
          out.write("\r\nEverybody\r\n</body>\r\n</html>\r\n ");
    }See. Any plain HTML code you put outside of the <%! %> tags is converted to out.printlns inside the _jspService method (in place where they occured in the JSP, not where the method you want to do the rendering is called...)
    So unless I completely misunderstood your intent here, this apprach does not work.

  • Inheritance and access control - "private protected"

    I'm reopening an old topic, seems to have been last discussed here 2-3 years ago.
    It concerns the concept of restricting access to class members to itself, and its subclasses. This is what "protected" does in C++ and "private protected" did in early versions of the Java language. This feature was removed from Java with a motivation along the lines of not being "simple", and "linear" (in line with the other access modes, each being a true subset of the next). Unfortunately, the article which explained Sun's position on this keyword combination seems to have been removed from the site, so I haven't been able to read its original text.
    But regardless of simplicity of implementation or explaining Java's access modifiers to newbies, I believe it is a fundamental part of OO programming for such an access mode to exist. The arguments for having the standard "private" mode in fact also apply for having a C++-style "protected" mode. (Arguing that classes within a package are related and it therefore doesn't hurt to also give them access to Java's "protected" members, is equally arguing that "private" is unneccessary, which noone of course believes.)
    The whole concept of inheritance and polymorphism and encapsulation builds on the access modes private, protected, and public (in the C++ senses). In Java the "package" concept was added - a nice feature! But I see no justification for it to negate the proper encapsulation of a class and its specializations.

    What effect upon inheritance other than hiding members
    from subclasses is there?
    None. And I cant think of another declaration that prevents members from being inherited but private.
    Of course the onus comes on the programmer with Java's
    definition of "protected" - but
    1) there is rarely a single programmer working within
    a package
    The point was the package is a unit which does not hide from itself. Just like all methods within a class can see each other, all classes within a package can, and all packages within a program can.
    2) it muddies the encapsulation in the design - when
    you see a "protected" method someone else, or yourself
    some time ago - wrote, how do you know if the design
    intention is to have it accessed solely by the class
    and its subclasses, or if it is indeed intended to be
    shared with the whole package? The only way to do
    this today is to always explicitly specify this in the
    comments, which may be lacking, inconsistent, and
    abused (since it isn't enforced).Encapsulation would be implementation hiding. Not method hiding. The only thing you should probably allow out of your package is an interface and a factory anyway.
    I understand where you are coming from, but I really have not had occasion to take issue with it. I can't think of a real codeing situation where this is required. OTOH, I can't think of a coding situation where I need to access a protected method from another class either.

  • Reopened topic "private protected" modifier

    I respond to reply in thread <http://forums.sun.com/thread.jspa?threadID=503004>. There I posted following:
    I would like to express that something like "private protected" is really missing. I develop packages for modelling of engineering structures. I have real and clear example why I need this. I was very surprised that I cannot open fields for subclasses only! Therefore I have to use "private" because I dont want to see these fields from another classes. It does not make sense in this way.
    There is my example:
    Imagine that there is a model for analysis of a engineering structure. This model can be 2D or 3D. Im developing three packages. First, the most abstract, contains classes useful in both 2D and 3D branches. For example class AbstractMassPoint, which has field mass. Second package is 2D brach and third package is 3D branch. In 2D and 3D branch are subclasses of AbstractMassPoint named MassPoint. I both versions of MassPoint class are relationships using mass field and one natural solution is access it directly without using getMass() method. But I like encapsulation and I dont want to see this field outside class AbstractMassPoint except subclases MassPoint which are natural subclasses. Modifier protected is too weak. I dont want to see this field in classes from package. Therefore current state is private modifier and something like getMass() methods. You can see source codes on my page (keywords: kitnarf's library, fydik).
    I like Java, but this is wrong. Why it is not possible?

    kitnarf wrote:
    There is my example:
    Imagine that there is a model for analysis of a engineering structure. This model can be 2D or 3D. Im developing three packages. First, the most abstract, contains classes useful in both 2D and 3D branches. For example class AbstractMassPoint, which has field mass. Second package is 2D brach and third package is 3D branch. In 2D and 3D branch are subclasses of AbstractMassPoint named MassPoint. I both versions of MassPoint class are relationships using mass field and one natural solution is access it directly without using getMass() method. But I like encapsulation and I dont want to see this field outside class AbstractMassPoint except subclases MassPoint which are natural subclasses. Modifier protected is too weak. I dont want to see this field in classes from package. Therefore current state is private modifier and something like getMass() methods. You can see source codes on my page (keywords: kitnarf's library, fydik).
    I like Java, but this is wrong. Why it is not possible?Although you might have a case for this very specific application how does it apply to the other million possible applications that one might create? If 900,000 of them could use it in such a way that it makes the code better then it is a good idea. But if only 1 could use it then it isn't.
    Given that I can get to private members if I want but it just isn't convenient to do so. So all you are doing is providing encouragement to someone to do the right thing. The best way to do that is correctly design the classes in the first place and provide correct and complete documentation. That works much better that trying to find ways to restrict it.

  • Issue in applying SSL selectively to Login JSP Page--Session getting lost.

    Hi,
    I am facing some issues with SSL configuration on my web site running on tomcat 5.5. I am using jdk 1.5 and form based authentication with JAAS framework.
    The SSL configuration is working perfectly when applied to complete web site, but starts giving problem when applied selectively to some JSP pages. At present I am trying to apply SSL just on the login page.
    When the login screen loads up, the URL in the browser has a protocol "*https*", as expected, but it doesn't gets changed to "*http*" once the user has successfully logged in. Why is the automatic change from https to http not ocurring?
    Also I want to know which is the default page, tomcat will direct the logged in user to, once successfully authenticated using form based login; Is there any way to change this default page to some other page. It looks like that tomcat automatically directs to index.html , once the user has been successfully authenticated, but I am not so sure. My index.html page is having 4 frames; the source of these frames are different JSP pages, which are not under SSL.
    My aim is to apply SSL just on login.jsp so that password doesn't travel in clear text. Once the user is authenticated he should see index.html and the address bar's URL should change it's protocol from https to http.
    Please, find below the code in my web.xml
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>CWA Application</web-resource-name>
    <url-pattern>/about.jsp</url-pattern>
    <url-pattern>/admin_listds.jsp</url-pattern>
    <http-method>DELETE</http-method>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    <http-method>PUT</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>*</role-name>
    </auth-constraint>
    <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
    <security-constraint>
    <web-resource-collection>
    <url-pattern>/*login.jsp*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>*</role-name>
    </auth-constraint>
    <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>CWA Application</realm-name>
    <form-login-config>
    <form-login-page>/login.jsp</form-login-page>
    <form-error-page>/login.jsp?error=true</form-error-page>
    </form-login-config>
    </login-config>
    <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
    My login. jsp has below code:
    <form name="login" method="POST" action='<%= response.encodeURL(*"j_security_check*") %>' >
    <tr>
    <td width="100%">
    <table width="260" border="0" cellspacing="0" cellpadding="1">
    <tr>
    <td align="left" valign="top" rowspan="4"><img src="images/space.gif" width="15" height="5"></td>
    <td align="right" class="login-user" nowrap ><p>User name: </p></td>
    <td align="left" valign="top"><input maxLength="64" name="j_username" size="20"></td>
    </tr>
    <tr>
    <td align="right" nowrap class="login-user"><p>Password: </p>
    </td>
    <td align="left" valign="top">
    <input maxLength=\"64\" tabindex="2" type="password" name="j_password" size="20">
    </td>
    </tr>
    </form>
    The entries in my server.xml are following:
    <Connector port="8080" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
    maxThreads="150" scheme="https" secure="true"
    keystoreFile="${java.home}\lib\security\cacerts" keystorePass="changeit"
    clientAuth="false" sslProtocol="TLS" />
    I have gone through the http://forums.sun.com/thread.jspa?threadID=197150 and tried implementing it; The filter as explained in the thread does gets called but the session values are still lost.
    Please note I am using javascript to go from secure "https" to "http" once the user has successfully logged in The javascript code is as below:
    top.location.href="http://localhost:8080/qtv/index.html." ;
    If I use response.sendRedirect("http://localhost:8080/qtv/index.html") for going to non-secure mode, the index.html page does not gets loaded properly. (Please note that my index.html is made of *4 frames*, as explained earlier. This is a legacy code and frames can't be removed).
    The reason for index.html not getting loaded properly is that the Address bar URL does NOT change its URL and protocol from https (https://localhost:8443/qtv/index.html ) to "*http*" (http://localhost:8080/qtv/index.html) when esponse.sendRedirect() is used ;this is the default behaviour of response.sendRedirect(). And because the protocol in address bar is https, index.html is not able to load the other JSP's in it's frames because of cross-frame-scripting security issues (The other JSP's to be loaded in frames are are NOT secure as discussed earlier).
    Please let know if any way out.
    Thanks,
    Masaai

    Hi
    try to set the maximum interval between requests
    eg:
    session.setMaxInactiveInterval(6000);
    vis

  • Calling a Method From JSP

    Hello People!!!
    I'm trying to call a method inside a viewObject from a JSP page using taglibs, but I don't know how to do this.
    Anyone can help me to do this call ??
    I need to pass a parameter to the method... this parameter is a column value!!
    thanks

    Are you trying to set a whereclause? If so you can always set the whereclause as an argument to your datasource tag.. An example of this is done in the Online Orders sample app at:
    http://otn.oracle.com/sample_code/products/jdev/content.html (see search_results.jsp)
    In general you can use the scriptable variable that you define for your BC4J Datasource to access different BC4J methods.
    Here's some code snippets showing different ways to access the BC4J Rowset (View Object) or the Application Module..
    <jbo:ApplicationModule id="Mypackage3Module" definition="Project3.Mypackage3Module" releasemode="Stateful" />
    <jbo:DataSource id="ds" appid="Mypackage3Module" viewobject="EmpView3" rangesize="3"/>
    <%
    ds.getRowSet().executeQuery();
    ds.getRowSet().first();
    ds.getRowSet()....(etc)
    // etc..
    or
    ds.getApplicationModule()....(etc)
    %>
    JSP Codeinsight will pop up your options..
    To ensure that Insight will work, make sure you have a closing scriplet marker.. "%>"...
    -Chris

  • Not sure how to use protected method in arraylisy

    Hi,
    Im wondering how to use the removeRange method in java arraylist, its a protected method which returns void.
    http://java.sun.com/j2se/1.3/docs/api/java/util/ArrayList.html#removeRange(int,%20int)
    So if my class extends Arraylist i should be able to call the method but the compiler states that it still has protected access in arraylist. Does this mean im still overriding the method in arraylist ? A little explanation of whats happeneing would be appreciated as much as an answer
    thanks

    In this codefinal class myClass extends java.util.ArrayList {
        private ArrayList array = new ArrayList();
        public myClass(ArrayList ary){
            for(int i=0;i<7;i++) {
                array.add(ary.get(i));
            ary.removeRange(0,7)
    }You are defining a class called myClass which extends ArrayList.
    You have a member variable called array which is an ArrayList
    You have a constructor which takes a parameter called ary which is an ArrayList
    Since ary is an ArrayList, you cannot call it's removeRange() method unless myClass is in the java.util package. Do not put your class in the java.util package.
    It seems like what you want to do is to move the items in one ArrayList to another ArrayList rather than copying them. I wrote a program to do this. Here it isimport java.util.*;
    public class Test3 {
      public static void main(String[] args) {
        MyClass myClass = new MyClass();
        for (int i=0; i<5; i++) myClass.add("Item-"+i);
        System.out.println("------ myClass loaded -------");
        for (int i=0; i<myClass.size(); i++) System.out.println(myClass.get(i));
        MyClass newClass = new MyClass(myClass);
        System.out.println("------ newClass created -------");
        for (int i=0; i<newClass.size(); i++) System.out.println(newClass.get(i));
        System.out.println("------ myClass now contains -------");
        for (int i=0; i<myClass.size(); i++) System.out.println(myClass.get(i));
    class MyClass extends java.util.ArrayList {
        public MyClass() {}
        public MyClass(MyClass ary){
            for(int i=0;i<ary.size();i++) add(ary.get(i));
            ary.removeRange(0,ary.size());
    }You should notice now that I don't create an ArrayList anywhere. Everything is a MyClass. By the way, class names are normally capitalized, variable names are not. Hence this line
    MyClass myClass = new MyClass();
    In the code above I create an empty MyClass and then populate it with 5 items and then print that list. Then I create a new MyClass using the constructor which takes a MyClass parameter. This copies the items from the parameter list into the newly created MyClass (which is an ArrayList) and then removes the items from the MyClass passed as a parameter. Back in the main() method, I then print the contents of the two MyClass objects.
    One thing which may be a little confusing is this line.
    for(int i=0;i<ary.size();i++) add(ary.get(i));
    the add() call doesn't refer to anything. What it really refers to is the newly created MyClass object which this constructor is building. This newly created object is the 'this' object. So the line above could be rewritten as
    for(int i=0;i<ary.size();i++) this.add(ary.get(i));
    Hopefully this helps a little. The problems you seem to be having are associated with object oriented concepts. You might try reading this
    http://sepwww.stanford.edu/sep/josman/oop/oop1.htm

  • Accessing java class and methods within JSP

    Hi All,
    I am writing a JSP page, and need to instantiate an object of a certain class within my package, in my JSP page.
    How do I do that? Do i use the <%import = "Whatever.class" %>
    Any help would be greatly appreciated.
    Kal.

    Hi.. Thanks for ur reply.
    I am actually having a problem with the import statement. So the part where you have mypackage.Myclass, it is not working for me.
    I am using Sun Forte.. and the directory is myprojects/test/Classes/MyClass.java
    so how would the import statement look like?
    Thanks
    Kal.
    Using directive for import statements:
    <%@ page
    import="java.util.*,java.sql.*,mypackage.MyClass" %>
    Then use scriptlet:
    <%! MyClass c= new MyClass(); %>
    <%! private void method() {...} %>
    <%= c.getxxx() %>
    ...and so on

  • Access to protected method is ot allowed

    Hi,
    there is class with a protected  method. I get the message
    "Access to protected method is ot allowed"
    How must such methods be called if they are protected ?
    Regards
    sas

    Erdem, please try to post in the correct forum.  ABAP Objects questions belong in this forum, not general.
    Second, Amit Khare is correct.  The concept of Public/Protected/Private methods and attributes is not limited to ABAP Objects.  It is a common concept to most object oriented programming languages.  But if your read the ABAP Help on the appropriate keywords, then it is explained very clearly.
    matt

  • Methods in JSP (repetitive things)

    I had posted this question before but didnt solve me problem.Here I ask it again.
    I alway thought that JSP should be used for display purpose.In that what to do if some lines of code are repeated many number of times,and since I cant have a method inside a JSP then I am wondering the solution will be to create a class and then write the output to the out variable.
    Please help.
    Thanks
    MS

    Coding to generate multiple table rows (or similar function) in a JSP should still be considered presentation-layer stuff. In other words, a method to repeatedly generate table rows is a display purpose, generally speaking. That said, custom tags go a long way to keeping your JSPs clean and pretty.

  • How to get protected method ?

    I thought i can get protected method of my class when calling a Class.getMethod(String, Class []) in another class which inside the same package. However, it seem that i can't do that because it throw me a NoSuchMethodException when the method was protected. I thought all classes in same package can access the protected methods or fields of each other ??? Why ?
    So, how i'm able to get the protected method in runtime ? (Hopefully no need to do anything with the SecurityManager)

    It is working
    Pls try the following program ...
    public class p1 {
    public static void main(String as[]) {
    p2 ps2 = new p2();
    ps2.abc();
    class p2 {
    protected void abc() {
    System.out.println("Hello");
    regards,
    namanc

Maybe you are looking for

  • Apps not showing up in privacy setting

    I have an iphone 4s i downloaded apps such as dropbox and viber a need to turn on the privacy settings. However these apps are not recognised by the phone as when i go into privacy dropbox and viber are nowhere to be seen.

  • Standard 'X' in a modal dialog box not working

    Hi, I have created a module pool and calling screen from main screen using Call screen.... Starting... ending... statement. It is a modal dialog box screen. As a standard a [X] appears on top right corner. But when I click it doesn't work. it does no

  • T431s Middle click not working (open new tabs in browser)

    Hi, I have a brand new t431s here, and I can not get the track point working as expected (and as on all previouse thinkpads since the i-series): expected behaviour: middle-click on link -> new tab middle click&hold and trackpoint-> scrolling I am not

  • IMS52 (with Direct LDAP Mode) Directory Failover

    I would like to configure all components of iMS5.2 for Directory Server failover. That should include (Direct LDAP) MTA, Messaging Express, authentication, Personal Address Book, Delegated Administration, etc. What are all the settings I need to conf

  • MDS Connection Database Question

    Hi there, My team is currently using Oracle BPM Suite to share process models and simulations between analysts (we are not doing any development work). We are currently using the BPM MDS connection internally to manage versions between Composer and J