Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7605567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:12:00+00:00 2026-05-31T00:12:00+00:00

Setup Mac OSX 10.6.8, Apache Tomcat 6.0.16, Java1.6.0_29, Eclipse IDE Indigo. I asked a

  • 0

Setup
Mac OSX 10.6.8, Apache Tomcat 6.0.16, Java1.6.0_29, Eclipse IDE Indigo.

I asked a similar question to this before at How to execute and include a Java API from a Web App project but the set up has since changed in that i now have the Java code in the WebAp

I am trying to invoke a Java Method from a JSP page and return the results. I have looked at a lot of posts but I’m afraid my lack of experience with either language is the main problem.

I have a JSP WebAp that searches an XML database and returns content to the user. I have been asked to integrate additional java code that searches predefined Websites and returns content.

I’ve played around with similar code to the below but I think I’m looking for something else

<%@ include file="/Applications/Tomcat/apache-tomcat-6.0.16/webapps/myWebApp/program.java" %>

Can anyone give me a better idea of what I’m looking for?

Also do you know if I have to edit anything else in the WebAp to connect the two files? The class files in the WebINF folder?

Any help is very much appreciated

Deepend


package sliceClient;

import java.util.List;


public class Run {

@Inject
private SliceSearcher sliceSearcher;

@Inject
private SliceCreator sliceCreator;

/**
 * @param args
 */
public static void main(String[] args) {
    Injector injector = Guice.createInjector(new GuiceInjector());
    Run r = injector.getInstance(Run.class);
    r.runSliceConsumer();
}

private void setSlicepediaProductionMode(boolean productionMode){
    sliceSearcher.setProductionMode(productionMode);
    sliceCreator.setProductionMode(productionMode);
}

public void runSliceConsumer() {
    System.out.println("Starting Slice Consumer");

    //Remove this line if the real slicepedia server is to be used
    setSlicepediaProductionMode(true);

    List<SliceHit> sliceHits = searchForSlices();
    if (sliceHits == null) {
        System.err.println("Timeout occurred while fetching slices");
        return;
    }
    if (!sliceHits.isEmpty()) {
        System.out.println("Found some slices Yuhuuuu ! :-) ");
        String sliceContent = createSlices(sliceHits);
        System.out.println("Slice content:");
        System.out.println(sliceContent);
    } else {
        System.out.println("No Slices were found for this query");
    }
    System.out.println("Slice Consumer stopped activity");
}

private String createSlices(List<SliceHit> sliceHits) {
    sliceCreator.setSliceHits(sliceHits);
    if (sliceCreator.run()) {
        SlicePackage slicePackage = sliceCreator.getNextSlicePackage();
        return slicePackage.getSliceContent();
    } else {
        return sliceCreator.getErrorMessage();
    }
}

private List<SliceHit> searchForSlices() {
    SlicepediaQuery sliceQuery = new SlicepediaQuery();


    sliceQuery.paramANNOTATION_READING_DIFFICULTY(new Double(30), "<");
    //Works
//      String dbConcept = "http://dbpedia.org/resource/human_rights";
//      sliceQuery.paramANNOTATION_CONCEPT_FEATURE_HAS_DBPEDIA(dbConcept,0.5, ">");
//      sliceQuery.paramHAS_NBR_OF_PARAGRAPHS(1,">");
//      sliceQuery.paramIsAnOpenSlice(true);
//      sliceQuery.paramHasNumberOfToken(80, ">");

    sliceSearcher.setSliceQuery(sliceQuery);
    if (sliceSearcher.run()) {
        return sliceSearcher.getSliceHits();

    } else {
        return null;

    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:12:01+00:00Added an answer on May 31, 2026 at 12:12 am

    First, the ugly way (maybe because so similar to php?):

    <%= com.example.MyUtility.getSomething() %>
    

    It is called a scriptlet and is considred a bad practice. In fact this is so wrong that I am ashamed of even writing this. What you should do instead is to have a front controller (a simple servlet will do the trick), place results in the request attributes and forward to a JSP, which in turns uses jstl or jsp el for output. Much more work, but better by an order of magnitude:

    In Servlet:

    request.setAttribute("someData", MyUtility.getSomething())
    RequestDispatcher dispatcher = request.getRequestDispatcher("page.jsp");
    dispatcher.forward(request, response);  
    

    In page.jsp:

    ${someData}
    

    There are various frameworks that can reduce the amount of boilerplate (spring-mvc is a simple example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem with my postgreSQL setup on my new Mac OSX Lion
How do I set up a shell script to execute from the Mac OSX
I am trying to get my Mac setup as a php server, however, as
I'm trying to install matplotlib on my mac setup. I find that setup.py has
In my setup I have an NSCollectionView of volumes connected to the mac. For
I'm looking for a good setup for learning C++ and eventually Python on Mac
I'm running Mac OSX on a MacBookPro (UK keyboard). I run windows XP under
I'm using TextMate 1.5.10 (Mac OSX 10.7.2) to write a perl modulino application .
I've just set up my first Android development environment consisting of Eclipse 3.5 Mac
Environment: Apache 2 shipped with Mac OS X Leopard; with no big changes in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.