Solved

call class function in jsp

Posted on 2003-12-05
9
829 Views
Last Modified: 2008-02-01
Hi pretty new to jsp/java but hopefully someone will be so kind as to help.

I currently have a jsp file that imports in various class files from within a jar file ie

<%@ page import="java.util.*" %>
<%@ page import="com.webapp.loc.*" %>

Unfortunately I am unable to edit the class files due to licensing but would like to call one of the functions within a class file independtly, how would I go about doing this ?

The problem I have is that within the class file the function I want to run is within an if statement which again I have no control over so ideally would like to call the function independtly from the jsp page, the lis I would like to use is :

 write(Menu.midLine(env, page.getNodeMenu()));

The above ius stored in a class file called : pageR.class   this also import other class file to run the menu.midLevel etc


Thanks,  off now to read up on jsp/java.



Darren.






0
Comment
Question by:kan3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9881444
Can you provide some more detail please?

What is the method that you want to call?  What is the method with the "if" statement?
0
 

Author Comment

by:kan3
ID: 9881450
Need to ignore the if statement because I have no control of the value that is passed, basically I want to run :  

write(Menu.midLine(env, page.getNodeMenu()));

within my jsp rather than within the class file




Like I say I am a newbie to jsp/java so apologies if I am not making sense.  Usually work with asp and php.


Darren.
0
 
LVL 4

Expert Comment

by:vk33
ID: 9881475
If I got it right, you want to change the logic of compiled class, right? It seems to be impossible, you need to change the souce code and recompile it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Accepted Solution

by:
jimmack earned 250 total points
ID: 9881491
Ah.

Is the write() method providing output that should be included in the HTML?

If so you could either do:

<%
    out.print(Menu.midLine(env, page.getNodeMenu()));
%>

or

<%= Menu.midLine(env, page.getNodeMenu())) %>
0
 

Author Comment

by:kan3
ID: 9881508
I could do that but then I would be breaking the license of the web app.

I just want to run the line :

write(Menu.midLine(env, page.getNodeMenu()));

from within my jsp page and that will use the class files.


Currently the line is within a class file but is within an if statement so for my requirements I can't use therefore I would just like to add this line directly in the jsp page which will run the calls from the class files, make sense ??


privatee from within class file pageR.class

private void pageH(Env env)
    {
        if(!onlyUse)
                    write(Menu.midLine(env, page.getNodeMenu()));
        }      
    }

I can't control onlyUse but inside want to run the line within this.


Thanks for help.


Darren.


0
 
LVL 15

Expert Comment

by:jimmack
ID: 9881515
You'll have a problem if write is not public.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9881518
Ignore my last comment.  It depends on what write() does.  Let us know what happens when you try the code from my earlier comment.
0

Featured Post

Free Tool: SSL Checker

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

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
squirrelPlay java challenge 40 160
nested if has else if 13 101
struts spring hibernate example 12 144
java operators 3 130
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
The goal of this blog is to: > note what has impeded us from reaching effective life on-call > provide 3 steps to mastering life on-call > highlight what will be achieved with effective life on-call
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question