MyEclipse Forums
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic Printable version Log in to check your private messages View next topic
Author Message
sonoerin
Post subject: proper project structure  PostPosted: Jul 12, 2011 - 11:38 PM
Veteran Member
Veteran Member


Joined: Jul 22, 2005
Posts: 107

I have a webapp that I run REST services in Tomcat. However, I am unable to get the html pages to show up to use javascript or css. Here is my project structure:

project
- src
- test
- target
--webapp
---lib
---css
-----style.css
---js
-----myjs.js
---home.html

I do have resources/services defined for / and /office so perhaps that is why its not being caught? Here is my web.xml:

Code:
<context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:applicationContext.xml</param-value>
   </context-param>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>
   <listener>
      <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
   </listener>
   <servlet>
      <servlet-name>MyServlet</servlet-name>
      <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>com.xxx.yyy.resources</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>MyServlet</servlet-name>
      <url-pattern>/*</url-pattern>
   </servlet-mapping>


I am hoping to use a html for each rest resource and pass JSON to it for JQuery. I would greatly appreciate any help or advice anyone can offer.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-joy
Post subject:   PostPosted: Jul 13, 2011 - 04:55 PM
Registered Member
Registered Member


Joined: Feb 03, 2009
Posts: 3442

sonoerin,

I am afraid the information you have given below is not enough for me to investigate this issue. What is the issue you are facing? What does your html show? Where have you declared your javascript / css. For debug purpose, could you move your javascript and css functions directly to your html to check if they render. Next verify the path of your javascript file and css file. You are facing development related issue. I would recommend you research on development forums

_________________
Joy
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
sonoerin
Post subject: rest project structure  PostPosted: Jul 20, 2011 - 06:49 PM
Veteran Member
Veteran Member


Joined: Jul 22, 2005
Posts: 107

I guess my question was really more about configuration. I used the wizard to setup a web service project, and I can use the created resources to actually receive a GET on the url. However, I would like to have a html page for each area so I can send/receive data back and forth. Probably I need a online tutorial that demonstrates:

/ (index.html would have javascript to send/receive data)
/office would have an office.html that handles the request

All the REST examples I have found seem to focus on the server side, but html or something must be on the UI - how do you set that up in the project?
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-tony
Post subject:   PostPosted: Jul 25, 2011 - 08:51 AM



Joined: Mar 09, 2011
Posts: 916

sonoerin,

I'm not really sure what you're trying to do. Web services, including ReST web services, is a means of communication between two machines, using HTTP (usually). Both ends need to write code to communicate. One end has the web service and the other has a program that uses that web service to obtain data or execute some functionality. It can be two server machines communicating or a server and a client program. MyEclipse provides tools that are, essentially, the client side of the communication, in order to test your service.

An HTML page is just a front end to a web application, not a web service. If you want to display HTML pages, then a web application is appropriate, not a web service, since you are essentially communicating between a real user and the server. However, the web application, behind the HTML pages, can communicate with a web service to carry out its functionality.

But I may be misunderstanding what you're after. If my reply doesn't give you any hints, could you explain what you want, in a different way, so we can better understand?

_________________
Tony
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
sonoerin
Post subject: clarification  PostPosted: Jul 25, 2011 - 02:08 PM
Veteran Member
Veteran Member


Joined: Jul 22, 2005
Posts: 107

My apologies for not explaining my project setup better.

Server
-------
Jersey/Spring/Hibernate


Client
-------
HTML/JSON/JQuery

What I am trying to do is when a visitor hits a page, the URL calls the resource on the server, which will do some action, and return JSON data to the HTML, where JQuery will handle it. I really don't want to use JSP, but when I try and run this, none of my html, css, or js gets applied. If I dynamically create html and return that, it does display, but again the html, css, and js are not.

Perhaps I am going down the wrong path with the HTML/JQuery approach? II just wanted something other than JSP's for this.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Support-Brian
Post subject:   PostPosted: Jul 26, 2011 - 06:49 AM
Moderator
Moderator


Joined: Aug 21, 2004
Posts: 2584

sonoerin,

I'm assuming that you do not intend to return complete HTML from your web service calls; rather you have complete HTML + CSS + JS pages which internally make calls to the web service. The web service returns data in JSON which you use to dynamically populate part of your rendered page using jQuery. Is this correct?

I think your problem may be the fact that you're mapping all requests to your server through the REST servlet
Code:
   <servlet-mapping>
      <servlet-name>MyServlet</servlet-name>
      <url-pattern>/*</url-pattern>
   </servlet-mapping>
I would recommend using a special pattern for your RESTful services, perhaps something like
Code:
   <servlet-mapping>
      <servlet-name>MyServlet</servlet-name>
      <url-pattern>/services/*</url-pattern>
   </servlet-mapping>
Then change all the calls to the web services in your code to use this URL instead. For the client side, make sure URLs being presented and used do not use the services URL - they will then simply be directly returned by the web server and should therefore render just fine. Try a simple page with no web service calls but with JS and CSS, does that work?

_________________
Brian
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits